summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-09 11:57:26 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-09 11:57:26 (GMT)
commitfdb63d1c161ff951969244906a77be016d9b2f02 (patch)
tree888c696e7c3b3f8fa1801d7a4ccf9e0901eb8da5
parent89034baf34d913daae0d53d0468885c603762d8a (diff)
downloadswift-fdb63d1c161ff951969244906a77be016d9b2f02.zip
swift-fdb63d1c161ff951969244906a77be016d9b2f02.tar.bz2
Fix segfault when Roster items are removed.
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.cpp10
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
index 1b77b26..2c3b4b2 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
@@ -38,8 +38,8 @@ void QtTreeWidgetItem::setBackgroundColor(unsigned long color) {
(color & 0xFF));
}
-void QtTreeWidgetItem::setExpanded(bool b) {
- expanded_ = true;
+void QtTreeWidgetItem::setExpanded(bool expanded) {
+ expanded_ = expanded;
emit changed(this);
}
@@ -70,6 +70,7 @@ QWidget* QtTreeWidgetItem::getExpandedRosterWidget() {
}
QtTreeWidgetItem::~QtTreeWidgetItem() {
+ parent_->removeChild(this);
qDeleteAll(children_);
}
@@ -83,6 +84,11 @@ void QtTreeWidgetItem::addChild(QtTreeWidgetItem* child) {
handleChanged(child);
}
+void QtTreeWidgetItem::removeChild(QtTreeWidgetItem* child) {
+ children_.removeAll(child);
+ handleChanged(this);
+}
+
void QtTreeWidgetItem::handleChanged(QtTreeWidgetItem* child) {
shownChildren_.clear();
for (int i = 0; i < children_.size(); i++) {
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h
index 73da92f..20e6f5d 100644
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.h
+++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h
@@ -26,6 +26,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
public:
~QtTreeWidgetItem();
void addChild(QtTreeWidgetItem* child);
+ void removeChild(QtTreeWidgetItem* child);
QtTreeWidgetItem* getParentItem();
int rowCount();
int rowOf(QtTreeWidgetItem* item);