diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-04 19:19:00 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-03-04 19:19:00 +0000 |
| commit | 70f07d3a84ebcc213420c8028a2bc3d1dd4110d4 (patch) | |
| tree | a9414b722ff5dc1948e4434ec17f1b6f6e919942 /src/ui | |
| parent | Remove regex hack added in 14650 (diff) | |
| download | inkscape-70f07d3a84ebcc213420c8028a2bc3d1dd4110d4.tar.gz inkscape-70f07d3a84ebcc213420c8028a2bc3d1dd4110d4.zip | |
Fix for bug 415471 and 1553182 related to undo with eraser tool
Fixed bugs:
- https://launchpad.net/bugs/1553182
(bzr r14688)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tools/eraser-tool.cpp | 89 |
1 files changed, 48 insertions, 41 deletions
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 8a3dbc66e..6b32b5901 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -702,49 +702,57 @@ void EraserTool::set_to_accumulated() { for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ SPItem *item = *i; SPUse *use = dynamic_cast<SPUse *>(item); - if (SP_IS_GROUP(item) || use ) { - continue; - } - Geom::OptRect bbox = item->desktopVisualBounds(); - if (bbox && bbox->intersects(*eraserBbox)) { - Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); - this->repr->parent()->appendChild(dup); - Inkscape::GC::release(dup); // parent takes over - selection->set(dup); - if (!this->nowidth) { - sp_selected_path_union(selection, desktop); - } - selection->add(item); - if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_set_property(css, "fill-rule", "evenodd"); - sp_desktop_set_style(desktop, css); - sp_repr_css_attr_unref(css); - css = 0; - } - if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); - } else { - sp_selected_path_diff_skip_undo(selection, desktop); - } - workDone = true; // TODO set this only if something was cut. - bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); - if(!break_apart){ - sp_selected_path_combine(desktop); - } else { - if(!this->nowidth){ - sp_selected_path_break_apart(desktop); + if (SP_IS_PATH(item) && SP_PATH(item)->nodesInPath () == 2){ + sp_object_ref( *i, 0 ); + SPItem *item = *i; + item->deleteObject(true); + sp_object_unref(item); + workDone = true; + workDone = true; + } else if (SP_IS_GROUP(item) || use ) { + /*Do nothing*/ + } else { + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox && bbox->intersects(*eraserBbox)) { + Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); + this->repr->parent()->appendChild(dup); + Inkscape::GC::release(dup); // parent takes over + selection->set(dup); + if (!this->nowidth) { + sp_selected_path_union_skip_undo(selection, desktop); } - } - if ( !selection->isEmpty() ) { - // If the item was not completely erased, track the new remainder. - std::vector<SPItem*> nowSel(selection->itemList()); - for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { - remainingItems.push_back(*i2); + selection->add(item); + if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "fill-rule", "evenodd"); + sp_desktop_set_style(desktop, css); + sp_repr_css_attr_unref(css); + css = 0; + } + if (this->nowidth) { + sp_selected_path_cut_skip_undo(selection, desktop); + } else { + sp_selected_path_diff_skip_undo(selection, desktop); + } + workDone = true; // TODO set this only if something was cut. + bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); + if(!break_apart){ + sp_selected_path_combine(desktop, true); + } else { + if(!this->nowidth){ + sp_selected_path_break_apart(desktop, true); + } + } + if ( !selection->isEmpty() ) { + // If the item was not completely erased, track the new remainder. + std::vector<SPItem*> nowSel(selection->itemList()); + for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { + remainingItems.push_back(*i2); + } } + } else { + remainingItems.push_back(item); } - } else { - remainingItems.push_back(item); } } } else { @@ -773,7 +781,6 @@ void EraserTool::set_to_accumulated() { } } } - // Remove the eraser stroke itself: sp_repr_unparent( this->repr ); this->repr = 0; |
