diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-08-09 14:37:57 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-08-09 14:37:57 (GMT) |
commit | b589aa3732712c31da44523fa60fc5c4bc92ea9b (patch) | |
tree | 8874c488a7d3f40669a69276dcbbdebb2fa3cd97 | |
parent | fdb63d1c161ff951969244906a77be016d9b2f02 (diff) | |
download | swift-contrib-b589aa3732712c31da44523fa60fc5c4bc92ea9b.zip swift-contrib-b589aa3732712c31da44523fa60fc5c4bc92ea9b.tar.bz2 |
Fix long-standing bug with a crash on quit after joining MUCs.
-rw-r--r-- | Swift/Controllers/MUCController.cpp | 3 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidgetItem.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidgetItem.h | 1 | ||||
-rw-r--r-- | Swiften/Roster/GroupRosterItem.h | 4 | ||||
-rw-r--r-- | Swiften/Roster/Roster.cpp | 6 |
5 files changed, 24 insertions, 11 deletions
diff --git a/Swift/Controllers/MUCController.cpp b/Swift/Controllers/MUCController.cpp index 37389a2..848f540 100644 --- a/Swift/Controllers/MUCController.cpp +++ b/Swift/Controllers/MUCController.cpp @@ -42,8 +42,7 @@ MUCController::MUCController ( MUCController::~MUCController() { delete muc_; - //don't crash on exit by masking this. FIXME. - //delete roster_; + delete roster_; } void MUCController::handleWindowClosed() { diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index 2c3b4b2..51784df 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -59,19 +59,32 @@ bool QtTreeWidgetItem::isShown() { QWidget* QtTreeWidgetItem::getCollapsedRosterWidget() { QWidget* widget = new QWidget(); - return widget; } QWidget* QtTreeWidgetItem::getExpandedRosterWidget() { QWidget* widget = new QWidget(); - return widget; } QtTreeWidgetItem::~QtTreeWidgetItem() { - parent_->removeChild(this); - qDeleteAll(children_); + //It's possible (due to the way the roster deletes items in unknown order when it is deleted) + // That the children will be deleted before the groups, or that the groups are deleted + // before the children. If the children are deleted first, they will let the parent know that + // They've been deleted. If the parent is deleted first, it must tell the children not to + // tell it when they're deleted. Everything will be deleted in the end, because all the + // widgets are owned by the Roster in Swiften. + if (parent_) { + parent_->removeChild(this); + } + + for (int i = 0; i < children_.size(); i++) { + children_[i]->parentItemHasBeenDeleted(); + } +} + +void QtTreeWidgetItem::parentItemHasBeenDeleted() { + parent_ = NULL; } QtTreeWidgetItem* QtTreeWidgetItem::getParentItem() { diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index 20e6f5d..1b898b0 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -40,6 +40,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { void setTextColor(unsigned long color); void setBackgroundColor(unsigned long color); void setExpanded(bool b); + void parentItemHasBeenDeleted(); void hide(); void show(); bool isShown(); diff --git a/Swiften/Roster/GroupRosterItem.h b/Swiften/Roster/GroupRosterItem.h index f96a868..4065fdb 100644 --- a/Swiften/Roster/GroupRosterItem.h +++ b/Swiften/Roster/GroupRosterItem.h @@ -18,8 +18,8 @@ class GroupRosterItem : public RosterItem { widget_ = factory->createTreeWidgetItem(tree); widget_->setExpanded(true); widget_->setText(name); - widget_->setTextColor(0xFFFFFF); - widget_->setBackgroundColor(0x969696); + widget_->setTextColor(0xFFFFFF); + widget_->setBackgroundColor(0x969696); } ~GroupRosterItem() { diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp index b51d8eb..b09964c 100644 --- a/Swiften/Roster/Roster.cpp +++ b/Swiften/Roster/Roster.cpp @@ -20,9 +20,9 @@ Roster::Roster(TreeWidget *treeWidget, TreeWidgetFactory *widgetFactory) : treeW } Roster::~Roster() { - foreach (RosterItem* item, items_) { - delete item; - } + foreach (RosterItem* item, items_) { + delete item; + } delete treeWidget_; } |