X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.cpp;h=3b18d036565ce071130e7aa82169a7f08fee26f1;hp=13b97f9baf7459641bbdd7089582a080723872f3;hb=a1d785ae12b3ec04b43e243f3397bb6f8ecf60d5;hpb=3c3a8f88f9aabd2f30df705fd1d8b147d6441968 diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 13b97f9b..3b18d036 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -57,13 +57,13 @@ bool AbstractTreeItem::newChilds(const QList &items) { } bool AbstractTreeItem::removeChild(int row) { - if(childCount() <= row) + if(row < 0 || childCount() <= row) return false; child(row)->removeAllChilds(); emit beginRemoveChilds(row, row); AbstractTreeItem *treeitem = _childItems.takeAt(row); - treeitem->deleteLater(); + delete treeitem; emit endRemoveChilds(); checkForDeletion(); @@ -94,7 +94,7 @@ void AbstractTreeItem::removeAllChilds() { while(childIter != _childItems.end()) { child = *childIter; childIter = _childItems.erase(childIter); - child->deleteLater(); + delete child; } emit endRemoveChilds(); @@ -117,14 +117,16 @@ bool AbstractTreeItem::reParent(AbstractTreeItem *newParent) { parent()->_childItems.removeAt(oldRow); emit parent()->endRemoveChilds(); - parent()->checkForDeletion(); - + AbstractTreeItem *oldParent = parent(); setParent(newParent); bool success = newParent->newChild(this); if(!success) qWarning() << "AbstractTreeItem::reParent(): failed to attach to new parent after removing from old parent! this:" << this << "new parent:" << newParent; + if(oldParent) + oldParent->checkForDeletion(); + return success; }