diff options
| author | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-08-28 08:09:45 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-08-28 08:09:45 +0000 |
| commit | b11930319d8af5dafda710ff8f4184083adf89fa (patch) | |
| tree | 240c06e17a09cf7e262bce6713cdbe86436d0cba /src | |
| parent | Extensions. Fix live preview crash in custom color extension when invalid val... (diff) | |
| download | inkscape-b11930319d8af5dafda710ff8f4184083adf89fa.tar.gz inkscape-b11930319d8af5dafda710ff8f4184083adf89fa.zip | |
Fix LP bug #622350: Discard events when desktop->event_context has not been set, instead of crashing.
(bzr r9728)
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.cpp | 8 | ||||
| -rw-r--r-- | src/event-context.cpp | 23 |
2 files changed, 22 insertions, 9 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index a93fb6a4a..1fdad010f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -636,9 +636,15 @@ SPDesktop::set_event_context (GtkType type, const gchar *config) event_context = next; } + // The event_context will be null. This means that it will be impossible + // to process any event invoked by the lines below. See for example bug + // LP #622350. Cutting and undoing again in the node tool resets the event + // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY + // events which cannot be handled and must be discarded. ec = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC); ec->next = event_context; event_context = ec; + // Now the event_context has been set again and we can process all events again sp_event_context_activate (ec); _event_context_changed_signal.emit (this, ec); } @@ -1367,7 +1373,7 @@ SPDesktop::emitToolSubselectionChanged(gpointer data) void SPDesktop::updateNow() { - sp_canvas_update_now(canvas); + sp_canvas_update_now(canvas); } void diff --git a/src/event-context.cpp b/src/event-context.cpp index 6184fb4c7..5d60379c8 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -937,8 +937,12 @@ gint sp_event_context_root_handler(SPEventContext * event_context, } gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event) { - gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event); - set_event_location(event_context->desktop, 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 = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event); + set_event_location(event_context->desktop, event); + } return ret; } @@ -972,12 +976,15 @@ gint sp_event_context_item_handler(SPEventContext * event_context, } gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event) { - gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event); - - if (!ret) { - ret = sp_event_context_virtual_root_handler(event_context, event); - } else { - set_event_location(event_context->desktop, 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 = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event); + if (!ret) { + ret = sp_event_context_virtual_root_handler(event_context, event); + } else { + set_event_location(event_context->desktop, event); + } } return ret; |
