aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-08-01 17:40:27 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-08-01 17:40:27 +0100
commit101de5b7151e996b026fa3705fc5ec5d065142f3 (patch)
treed7ca38f997fd2740bf0c615c78d74e70860756a6
parent2743d0fa9d785f994fd1bf7908f5c2824a81938a (diff)
downloadnextpnr-101de5b7151e996b026fa3705fc5ec5d065142f3.tar.gz
nextpnr-101de5b7151e996b026fa3705fc5ec5d065142f3.tar.bz2
nextpnr-101de5b7151e996b026fa3705fc5ec5d065142f3.zip
gui: treemodel: unregister from parent when we get destroyed
This fixes mysterious crashes when a new context was being loaded. The 'Bels', 'Wires', and 'Nets' roots would get replaced by new ones in TreeModel::Model::loadContext, but they would not get unregistered from their parent.
-rw-r--r--gui/treemodel.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/gui/treemodel.h b/gui/treemodel.h
index 4c3f64c3..c3f9fe88 100644
--- a/gui/treemodel.h
+++ b/gui/treemodel.h
@@ -62,6 +62,8 @@ class Item
void addChild(Item *child) { children_.append(child); }
+ void deleteChild(Item *child) { children_.removeAll(child); }
+
public:
Item(QString name, Item *parent) : name_(name), parent_(parent)
{
@@ -100,7 +102,12 @@ class Item
virtual bool canFetchMore() const { return false; }
virtual void fetchMore() {}
- ~Item() {}
+ ~Item()
+ {
+ if (parent_ != nullptr) {
+ parent_->deleteChild(this);
+ }
+ }
};
// IdString is an Item that corresponds to a real element in Arch.