From 5e940843907071e6093c010f0be08d15cb0fb46c Mon Sep 17 00:00:00 2001 From: buliabyak Date: Fri, 12 May 2006 20:09:24 +0000 Subject: [PATCH] memleak; move deleting empty paths until after all nodes are deleted --- src/nodepath.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 9be8b4ff2..4a9493483 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1870,28 +1870,35 @@ void sp_node_delete_preserve(GList *nodes_to_delete) sp_nodepath_update_handles(nodepath); + if (!g_slist_find(nodepaths, nodepath)) + nodepaths = g_slist_prepend (nodepaths, nodepath); + } + + for (GSList *i = nodepaths; i; i = i->next) { + // FIXME: when/if we teach node tool to have more than one nodepath, deleting nodes from + // different nodepaths will give us one undo event per nodepath + Inkscape::NodePath::Path *nodepath = (Inkscape::NodePath::Path *) i->data; // if the entire nodepath is removed, delete the selected object. if (nodepath->subpaths == NULL || + //FIXME: a closed path CAN legally have one node, it's only an open one which must be + //at least 2 sp_nodepath_get_node_count(nodepath) < 2) { SPDocument *document = sp_desktop_document (nodepath->desktop); sp_nodepath_destroy(nodepath); g_list_free(nodes_to_delete); nodes_to_delete = NULL; - //is the next line necessary? + //FIXME: The following line will be wrong when we have mltiple nodepaths: we only want to + //delete this nodepath's object, not the entire selection! (though at this time, this + //does not matter) sp_selection_delete(); sp_document_done (document); - return; + } else { + sp_nodepath_update_repr(nodepath); + sp_nodepath_update_statusbar(nodepath); } - - if (!g_slist_find(nodepaths, nodepath)) - nodepaths = g_slist_prepend (nodepaths, nodepath); } - for (GSList *i = nodepaths; i; i = i->next) { - Inkscape::NodePath::Path *nodepath = (Inkscape::NodePath::Path *) i->data; - sp_nodepath_update_repr(nodepath); - sp_nodepath_update_statusbar(nodepath); - } + g_slist_free (nodepaths); } /** -- 2.30.2