Code

fix crash when simplifying an lpe path: deleting the list didn't release the referenc...
authorbuliabyak <buliabyak@users.sourceforge.net>
Sat, 19 Jul 2008 04:33:41 +0000 (04:33 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sat, 19 Jul 2008 04:33:41 +0000 (04:33 +0000)
src/sp-lpe-item.cpp

index 229ae326eddcff8c95bd3aa6514db2bdf081da5e..2eecd8e45904b3bf86babb3458c852f487de6b54 100644 (file)
@@ -129,8 +129,6 @@ sp_lpe_item_finalize(GObject *object)
     if (((GObjectClass *) (parent_class))->finalize) {
         (* ((GObjectClass *) (parent_class))->finalize)(object);
     }
-
-    delete SP_LPE_ITEM(object)->path_effect_list;
 }
 
 /**
@@ -154,12 +152,21 @@ sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r
 static void
 sp_lpe_item_release(SPObject *object)
 {
-    SPLPEItem *lpeitem;
-    lpeitem = (SPLPEItem *) object;
+    SPLPEItem *lpeitem = (SPLPEItem *) object;
 
     lpeitem->lpe_modified_connection.disconnect();
     lpeitem->lpe_modified_connection.~connection();
 
+    PathEffectList::iterator it = lpeitem->path_effect_list->begin();
+    while ( it != lpeitem->path_effect_list->end() ) {
+        // unlink and delete all references in the list
+        (*it)->unlink();
+        delete *it;
+        it = lpeitem->path_effect_list->erase(it);
+    }
+    // delete the list itself
+    delete SP_LPE_ITEM(object)->path_effect_list;
+
     if (((SPObjectClass *) parent_class)->release)
         ((SPObjectClass *) parent_class)->release(object);
 }