mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-21 10:47:16 +01:00
fixed #1661 "Crash after deleting firewall" a sequence where user deleted
an object and then hit "Back" button caused crash.
This commit is contained in:
parent
387bce14ca
commit
e95f8df3c8
@ -1,3 +1,9 @@
|
||||
2010-08-04 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* ObjectManipulator_tree_ops.cpp (ObjectManipulator::removeObjectFromHistory):
|
||||
fixed #1661 "Crash after deleting firewall" a sequence where user deleted
|
||||
an object and then hit "Back" button caused crash.
|
||||
|
||||
2010-08-03 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* pixAdvancedDialog.cpp (pixAdvancedDialog): fixed SF bug #3038948
|
||||
|
||||
@ -1136,10 +1136,10 @@ void ObjectManipulator::selectionChanged(QTreeWidgetItem *cur)
|
||||
FWObject *o = obj;
|
||||
//if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer();
|
||||
|
||||
if (history.empty() || otvi!=history.top().item() )
|
||||
if (history.empty() || otvi!=history.back().item() )
|
||||
{
|
||||
mw->enableBackAction();
|
||||
history.push( HistoryItem(otvi, o->getId()) );
|
||||
history.push_back( HistoryItem(otvi, o->getId()) );
|
||||
}
|
||||
|
||||
//currentObj = obj;
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
|
||||
#include "UsageResolver.h"
|
||||
|
||||
#include <stack>
|
||||
#include <set>
|
||||
|
||||
class ObjectTreeView;
|
||||
@ -73,7 +72,14 @@ class HistoryItem {
|
||||
HistoryItem(ObjectTreeViewItem *oi, int id) { itm=oi; objId=id; }
|
||||
~HistoryItem();
|
||||
ObjectTreeViewItem* item() { return itm; }
|
||||
int id() { return objId; }
|
||||
int id() const { return objId; }
|
||||
};
|
||||
|
||||
class FindHistoryItemByObjectId {
|
||||
int id;
|
||||
public:
|
||||
FindHistoryItemByObjectId(int i) { id = i; }
|
||||
bool operator()(const HistoryItem &itm);
|
||||
};
|
||||
|
||||
class ObjectManipulator : public QWidget
|
||||
@ -84,7 +90,7 @@ class ObjectManipulator : public QWidget
|
||||
std::vector<QTreeWidget*> idxToTrees;
|
||||
int previous_lib_index;
|
||||
QSet<int> ids ;
|
||||
std::stack<HistoryItem> history;
|
||||
std::list<HistoryItem> history;
|
||||
int cacheHits;
|
||||
|
||||
//libfwbuilder::FWObject *currentObj;
|
||||
@ -299,6 +305,8 @@ public:
|
||||
void openObjectInTree(libfwbuilder::FWObject *obj, bool register_in_history);
|
||||
void openObjectInTree(ObjectTreeViewItem *otvi, bool register_in_history);
|
||||
|
||||
void removeObjectFromHistory(libfwbuilder::FWObject *obj);
|
||||
|
||||
libfwbuilder::FWObject* duplicateObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj);
|
||||
|
||||
|
||||
@ -415,13 +415,20 @@ void ObjectManipulator::back()
|
||||
{
|
||||
if (!history.empty())
|
||||
{
|
||||
history.pop();
|
||||
history.pop_back();
|
||||
|
||||
/* skip objects that have been deleted */
|
||||
/* skip objects that have been deleted.
|
||||
*
|
||||
* But see removeObjectFromHistory() which is now called by
|
||||
* removeObjectFromTreeView() it may not be necessary to do this
|
||||
* additional check here, especially since according to #1661 it
|
||||
* probably does not work anyway.
|
||||
*
|
||||
*/
|
||||
while ( ! history.empty())
|
||||
{
|
||||
if (m_project->db()->findInIndex( history.top().id() )!=NULL) break;
|
||||
history.pop();
|
||||
if (m_project->db()->findInIndex( history.back().id() )!=NULL) break;
|
||||
history.pop_back();
|
||||
}
|
||||
|
||||
if (history.empty())
|
||||
@ -430,11 +437,11 @@ void ObjectManipulator::back()
|
||||
return;
|
||||
}
|
||||
|
||||
openObjectInTree( history.top().item(), false );
|
||||
openObjectInTree( history.back().item(), false );
|
||||
|
||||
if (mw->isEditorVisible())
|
||||
{
|
||||
ObjectTreeViewItem *otvi=history.top().item();
|
||||
ObjectTreeViewItem *otvi=history.back().item();
|
||||
switchObjectInEditor(otvi->getFWObject());
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,6 +244,8 @@ void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj)
|
||||
|
||||
void ObjectManipulator::removeObjectFromTreeView(FWObject *obj)
|
||||
{
|
||||
removeObjectFromHistory(obj);
|
||||
|
||||
// QTreeWidget *objTreeView = idxToTrees[ getIdxForLib(getCurrentLib()) ];
|
||||
int current_lib_idx = m_objectManipulator->libs->currentIndex();
|
||||
QTreeWidget *objTreeView = idxToTrees[current_lib_idx];
|
||||
@ -259,6 +261,46 @@ void ObjectManipulator::removeObjectFromTreeView(FWObject *obj)
|
||||
}
|
||||
}
|
||||
|
||||
bool FindHistoryItemByObjectId::operator()(const HistoryItem &itm)
|
||||
{
|
||||
return (itm.id() == id);
|
||||
}
|
||||
|
||||
void ObjectManipulator::removeObjectFromHistory(FWObject *obj)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ObjectManipulator::removeObjectFromHistory"
|
||||
<< "obj:" << obj->getName().c_str()
|
||||
<< "id=" << obj->getId()
|
||||
<< "history.size()=" << history.size();
|
||||
|
||||
history.remove_if(FindHistoryItemByObjectId(obj->getId()));
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug() << "ObjectManipulator::removeObjectFromHistory"
|
||||
<< "history.size()=" << history.size();
|
||||
|
||||
if (history.empty()) mw->enableBackAction();
|
||||
|
||||
#if 0
|
||||
int obj_id = obj->getId();
|
||||
list<HistoryItem> tmp_list;
|
||||
while (!history.empty())
|
||||
{
|
||||
HistoryItem itm = history.top();
|
||||
history.pop();
|
||||
if (obj_id == itm.id()) continue;
|
||||
tmp_list.push_back(itm);
|
||||
}
|
||||
|
||||
while (!tmp_list.empty())
|
||||
{
|
||||
history.push(tmp_list.back());
|
||||
tmp_list.pop_back();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObjectManipulator::updateLibColor(FWObject *lib)
|
||||
{
|
||||
QString clr = lib->getStr("color").c_str();
|
||||
@ -322,7 +364,7 @@ void ObjectManipulator::clearObjects()
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects %p start",this);
|
||||
|
||||
while (history.size()!=0) history.pop();
|
||||
while (history.size()!=0) history.pop_back();
|
||||
|
||||
int N = m_objectManipulator->libs->count();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user