[Kst] branches/work/kst/hierarchy/kst/src/libkst

Eli Fidler eli at staikos.net
Fri Jan 5 23:42:24 CET 2007


SVN commit 620404 by fidler:

fix deletion of objects
    - remove from tree before list to avoid having the object deleted
      out from under us
    - check if object is in collection before trying to delete
    - more debugging


 M  +25 -1     kstobjectcollection.h  


--- branches/work/kst/hierarchy/kst/src/libkst/kstobjectcollection.h #620403:620404
@@ -351,13 +351,37 @@
     return false;
   }
 
+  if (!_list.contains(o)) {
+#if NAMEDEBUG > 1
+    kstdDebug() << "Trying to delete a non-existant object from the collection: " << o->tag().tagString() << endl;
+#endif
+    return false;
+  }
+
+#if NAMEDEBUG > 1
+    kstdDebug() << "Removing object from the collection: " << o->tag().tagString() << endl;
+#endif
+
+#if NAMEDEBUG > 2
+    kstdDebug() << "  fetching related nodes" << endl;
+#endif
   QValueList<KstObjectTreeNode<T> *> relNodes = relatedNodes(o);
 
-  _list.remove(o);
+#if NAMEDEBUG > 2
+    kstdDebug() << "  removing object from tree" << endl;
+#endif
   bool ok = _root.removeDescendant(o, &_index);
 
   if (ok) {
+#if NAMEDEBUG > 2
+    kstdDebug() << "  updating display components" << endl;
+#endif
     updateDisplayComponents(relNodes);
+
+#if NAMEDEBUG > 2
+    kstdDebug() << "  removing object from list" << endl;
+#endif
+    _list.remove(o);
   }
 
   return ok;


More information about the Kst mailing list