Code

Reduce undo history items when nothing is selected
authorjoncruz <joncruz@users.sourceforge.net>
Sun, 27 Apr 2008 08:41:25 +0000 (08:41 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Sun, 27 Apr 2008 08:41:25 +0000 (08:41 +0000)
src/eraser-context.cpp

index 3d142a9d0365584468cd42300d156cdce366485c..c787f0799bcf00ccdb2e1d824ef4daec8eaaf1f7 100644 (file)
@@ -790,6 +790,7 @@ static void
 set_to_accumulated(SPEraserContext *dc)
 {
     SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop;
+    bool workDone = false;
 
     if (!sp_curve_empty(dc->accumulated)) {
         NArtBpath *abp;
@@ -838,6 +839,7 @@ set_to_accumulated(SPEraserContext *dc)
                         selection->set(item);
                         selection->add(dup);
                         sp_selected_path_diff_skip_undo();
+                        workDone = true; // TODO set this only if something was cut.
                         if ( !selection->isEmpty() ) {
                             // If the item was not completely erased, add it back to the selection.
                             GSList const *selected2 = g_slist_copy(const_cast<GSList *>(selection->itemList()));
@@ -869,8 +871,13 @@ set_to_accumulated(SPEraserContext *dc)
         }
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, 
-                     _("Draw eraser stroke"));
+
+    if ( workDone ) {
+        sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, 
+                         _("Draw eraser stroke"));
+    } else {
+        sp_document_cancel(sp_desktop_document(desktop));
+    }
 }
 
 static void