summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-03-04 19:19:00 +0000
committerjabiertxof <info@marker.es>2016-03-04 19:19:00 +0000
commit70f07d3a84ebcc213420c8028a2bc3d1dd4110d4 (patch)
treea9414b722ff5dc1948e4434ec17f1b6f6e919942
parentRemove regex hack added in 14650 (diff)
downloadinkscape-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)
-rw-r--r--src/path-chemistry.cpp18
-rw-r--r--src/path-chemistry.h4
-rw-r--r--src/ui/tools/eraser-tool.cpp89
3 files changed, 60 insertions, 51 deletions
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 7b52ac2e1..15d3f0f99 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -52,7 +52,7 @@ inline bool less_than_items(SPItem const *first, SPItem const *second)
}
void
-sp_selected_path_combine(SPDesktop *desktop)
+sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *doc = desktop->getDocument();
@@ -172,10 +172,10 @@ sp_selected_path_combine(SPDesktop *desktop)
// move to the position of the topmost, reduced by the number of deleted items
repr->setPosition(position > 0 ? position : 0);
-
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE,
- _("Combine"));
-
+ if ( !skip_undo ) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE,
+ _("Combine"));
+ }
selection->set(repr);
Inkscape::GC::release(repr);
@@ -188,7 +188,7 @@ sp_selected_path_combine(SPDesktop *desktop)
}
void
-sp_selected_path_break_apart(SPDesktop *desktop)
+sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
@@ -283,8 +283,10 @@ sp_selected_path_break_apart(SPDesktop *desktop)
desktop->clearWaitingCursor();
if (did) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
- _("Break apart"));
+ if ( !skip_undo ) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
+ _("Break apart"));
+ }
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
diff --git a/src/path-chemistry.h b/src/path-chemistry.h
index 35ab923c0..7b9beaed8 100644
--- a/src/path-chemistry.h
+++ b/src/path-chemistry.h
@@ -25,8 +25,8 @@ class Node;
typedef unsigned int guint32;
-void sp_selected_path_combine (SPDesktop *desktop);
-void sp_selected_path_break_apart (SPDesktop *desktop);
+void sp_selected_path_combine (SPDesktop *desktop, bool skip_undo = false);
+void sp_selected_path_break_apart (SPDesktop *desktop, bool skip_undo = false);
// interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available
void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desktop, bool interactive = true);
void sp_selected_to_lpeitems(SPDesktop *desktop);
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;