From: buliabyak Date: Mon, 29 Dec 2008 05:31:53 +0000 (+0000) Subject: fix crash, allow combine to work transparently on groups X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e0c38bd294fd720cebbabeda1a0d87259f68bf7f;p=inkscape.git fix crash, allow combine to work transparently on groups --- diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 0227e9caf..6ef4b2742 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -36,6 +36,7 @@ #include "desktop-handles.h" #include "box3d.h" #include <2geom/pathvector.h> +#include "selection-chemistry.h" #include "path-chemistry.h" void @@ -44,8 +45,8 @@ sp_selected_path_combine(SPDesktop *desktop) Inkscape::Selection *selection = sp_desktop_selection(desktop); SPDocument *doc = sp_desktop_document(desktop); - if (g_slist_length((GSList *) selection->itemList()) < 2) { - sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select at least two objects to combine.")); + if (g_slist_length((GSList *) selection->itemList()) < 1) { + sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); return; } @@ -54,10 +55,13 @@ sp_selected_path_combine(SPDesktop *desktop) desktop->setWaitingCursor(); GSList *items = g_slist_copy((GSList *) selection->itemList()); + + items = sp_degroup_list (items); // descend into any groups in selection + GSList *to_paths = NULL; for (GSList *i = items; i != NULL; i = i->next) { SPItem *item = (SPItem *) i->data; - if (!SP_IS_PATH(item)) + if (!SP_IS_PATH(item) && !SP_IS_GROUP(item)) to_paths = g_slist_prepend(to_paths, item); } GSList *converted = NULL; @@ -66,6 +70,8 @@ sp_selected_path_combine(SPDesktop *desktop) for (GSList *i = converted; i != NULL; i = i->next) items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data))); + items = sp_degroup_list (items); // converting to path may have added more groups, descend again + items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); items = g_slist_reverse(items);