From a06c4852edb10e38fce19fd2df3833c03b6a15e4 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 8 May 2015 00:12:09 +0200 Subject: fix crash when converting a group of objects to path (bzr r14121) --- src/path-chemistry.cpp | 8 ++++++-- src/selection-chemistry.cpp | 16 ++++++++++++---- src/ui/tools/eraser-tool.cpp | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 8d2695b85..98148b916 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -388,7 +388,9 @@ sp_item_list_to_curves(const std::vector &items, std::vector& if (repr) { to_select.insert(to_select.begin(),repr); did = true; - selected.erase(find(selected.begin(),selected.end(),item)); + std::vector::iterator element=find(selected.begin(),selected.end(),item); + if(element != selected.end()) + selected.erase(find(selected.begin(),selected.end(),item)); } continue; @@ -413,7 +415,9 @@ sp_item_list_to_curves(const std::vector &items, std::vector& continue; did = true; - selected.erase(find(selected.begin(),selected.end(),item)); + std::vector::iterator element=find(selected.begin(),selected.end(),item); + if(element != selected.end()) + selected.erase(element); // remember the position of the item gint pos = item->getRepr()->position(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 8bc62d4b9..3a68b03e5 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3922,7 +3922,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { reprs_to_group.push_back(static_cast(i->data)->getRepr()); - items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast(i->data))); + std::vector::iterator element = find(items_to_select.begin(),items_to_select.end(),static_cast(i->data)); + if(element != items_to_select.end()) + items_to_select.erase(element); } sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); @@ -3972,7 +3974,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ Inkscape::XML::Node *spnew = current->duplicate(xml_doc); gint position = current->position(); - items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); + std::vector::iterator element = find(items_to_select.begin(),items_to_select.end(),item); + if(element != items_to_select.end()) + items_to_select.erase(element); current->parent()->appendChild(group); sp_repr_unparent(current); group->appendChild(spnew); @@ -3996,7 +4000,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = items_to_delete; NULL != i; i = i->next) { SPObject *item = reinterpret_cast(i->data); item->deleteObject(false); - items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); + std::vector::iterator element = find(items_to_select.begin(),items_to_select.end(),item); + if(element != items_to_select.end()) + items_to_select.erase(element); } g_slist_free(items_to_delete); @@ -4121,7 +4127,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { SPGroup *group = dynamic_cast(static_cast(i->data)); if (group) { - items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group)); + std::vector::iterator element = find(items_to_select.begin(),items_to_select.end(),group); + if(element != items_to_select.end()) + items_to_select.erase(element); std::vector children; sp_item_group_ungroup(group, children, false); items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend()); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 01b75fdb4..0af347bef 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -674,7 +674,9 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); + std::vector::iterator element = find(toWorkOn.begin(),toWorkOn.end(),acid); + if(element != toWorkOn.end()) + toWorkOn.erase(element); } else { toWorkOn= selection->itemList(); wasSelection = true; -- cgit v1.2.3