From df83396bcf937ba927ef36de53416241b2ad241c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 21 Nov 2013 21:12:34 +0100 Subject: fix memleak (bzr r12826) --- src/selection-chemistry.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 26e575439..d6879f91c 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2916,6 +2916,8 @@ void sp_selection_to_guides(SPDesktop *desktop) sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); } + g_slist_free(items); + DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } -- cgit v1.2.3 From 5d68e962f24fff66b61dc31f948b815b14957fbe Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 21 Nov 2013 21:51:50 +0100 Subject: fix crash bug 1253721, document code with explanation Fixed bugs: - https://launchpad.net/bugs/1253721 (bzr r12827) --- src/selection-chemistry.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index d6879f91c..aa8c1d222 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -372,10 +372,10 @@ static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) { for (GSList const *i = items ; i ; i = i->next ) { - sp_object_ref((SPObject *)i->data, NULL); + sp_object_ref(static_cast(i->data), NULL); } for (GSList const *i = items; i != NULL; i = i->next) { - SPItem *item = reinterpret_cast(i->data); + SPItem *item = static_cast(i->data); item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); } @@ -403,11 +403,11 @@ void sp_selection_delete(SPDesktop *desktop) return; } - GSList const *selected = g_slist_copy(const_cast(selection->itemList())); + GSList *selected = g_slist_copy(const_cast(selection->itemList())); selection->clear(); sp_selection_delete_impl(selected); - g_slist_free(const_cast(selected)); - reinterpret_cast(desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + g_slist_free(selected); + desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); /* a tool may have set up private information in it's selection context * that depends on desktop items. I think the only sane way to deal with @@ -2879,17 +2879,13 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) _("Objects to marker")); } -static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool wholegroups) { +static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item) && !wholegroups) { for (GSList *i = sp_item_group_item_list(SP_GROUP(item)); i != NULL; i = i->next) { - sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); + sp_selection_to_guides_recursive(static_cast(i->data), wholegroups); } } else { item->convert_to_guides(); - - if (deleteitem) { - item->deleteObject(true); - } } } @@ -2909,11 +2905,20 @@ void sp_selection_to_guides(SPDesktop *desktop) } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool deleteitem = !prefs->getBool("/tools/cvg_keep_objects", 0); + bool deleteitems = !prefs->getBool("/tools/cvg_keep_objects", 0); bool wholegroups = prefs->getBool("/tools/cvg_convert_whole_groups", 0); + // If an object is earlier in the selection list than its clone, and it is deleted, then the clone will have changed + // and its entry in the selection list is invalid (crash). + // Therefore: first convert all, then delete all. + for (GSList const *i = items; i != NULL; i = i->next) { - sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); + sp_selection_to_guides_recursive(static_cast(i->data), wholegroups); + } + + if (deleteitems) { + selection->clear(); + sp_selection_delete_impl(items); } g_slist_free(items); -- cgit v1.2.3 From 8210096c61e59b2f3122a46605937c5ccd140cc3 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 21 Nov 2013 22:41:39 +0100 Subject: the C++11 fails without this small change in constness of a GSList iterator (bzr r12829) --- src/graphlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index b0e00211a..7e10ccca1 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -106,7 +106,7 @@ void graphlayout(GSList const *const items) { return; } - using Inkscape::Util::GSListConstIterator; + using Inkscape::Util::GSListIterator; list selected; filterConnectors(items,selected); if (selected.empty()) return; @@ -167,7 +167,7 @@ void graphlayout(GSList const *const items) { GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); list connectors; - connectors.insert >(connectors.end(),nlist,NULL); + connectors.insert >(connectors.end(),nlist,NULL); for (list::iterator j(connectors.begin()); j != connectors.end(); ++j) { -- cgit v1.2.3 From 7348cf1e4e3ef512d32007931c5fb144784db9e2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 21 Nov 2013 23:41:17 +0100 Subject: reorder header file includes. Because glibmm depends on a deprecated/threads.h of glib, it has to be included first. (bzr r12830) --- src/main.cpp | 5 +++-- src/ui/dialog/ocaldialogs.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index c6427dc6f..9f5a95ffe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,12 +26,13 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "path-prefix.h" // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include -#include "ui/widget/panel.h" +#include "ui/widget/panel.h" // This has to be the first to include because of Glibmm's dependence on a deprecated feature... + +#include "path-prefix.h" #ifdef HAVE_IEEEFP_H #include diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index ca0edfadd..417df9a27 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -16,13 +16,14 @@ # include #endif +#include "ocaldialogs.h" + #include // rename() #include // close() #include // errno #include // strerror() #include "path-prefix.h" -#include "ocaldialogs.h" #include "filedialogimpl-gtkmm.h" #include "interface.h" #include "gc-core.h" -- cgit v1.2.3