diff options
| -rw-r--r-- | src/document-undo.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 14 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.h | 1 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 312ccb7f8..bad4d6c81 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -242,7 +242,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_return_val_if_fail (doc->priv->sensitive, FALSE); doc->priv->sensitive = FALSE; doc->priv->seeking = true; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 6c7867633..f8868ec0e 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -57,6 +57,7 @@ #include "shape-editor.h" #include "sp-guide.h" #include "color.h" +#include "document-undo.h" // globals for temporary switching to selector by space static bool selector_toggled = FALSE; @@ -977,9 +978,16 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; - if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash - // (see the comment in SPDesktop::set_event_context, and bug LP #622350) - //ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->root_handler(event_context, event); + if (event_context) { + // We want to disable undo while we drag anything + SPDocument *document = sp_desktop_document(event_context->desktop); + if (event->type == GDK_BUTTON_PRESS) { + event_context->undo_sensitive = DocumentUndo::getUndoSensitive(document); + DocumentUndo::setUndoSensitive(document, false); + } else if (event->type == GDK_BUTTON_RELEASE) { + DocumentUndo::setUndoSensitive(document, event_context->undo_sensitive); + } + ret = event_context->root_handler(event); set_event_location(event_context->desktop, event); diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 7ed5875b1..068bc6402 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -119,6 +119,7 @@ public: gint xp, yp; ///< where drag started gint tolerance; bool within_tolerance; ///< are we still within tolerance of origin + bool undo_sensitive; /// Was undo previously sensitive before drag SPItem *item_to_select; ///< the item where mouse_press occurred, to ///< be selected if this is a click not drag |
