From: Rob Norris Date: Tue, 9 Oct 2012 18:47:38 +0000 (+0100) Subject: Prevent obscure crash on key press when layer is not selected but create track tool... X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/c68b3c0659ec3a2d5597bd5db771e544a3e669b6 Prevent obscure crash on key press when layer is not selected but create track tool is enabled Ensure secondary key press processing only occurs for window level tools Fixup commit SHA1: a71145218059e3e8153b9e58493d3a0d57743324 --- diff --git a/src/vikwindow.c b/src/vikwindow.c index ef4e2bc6..4818ee17 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -489,9 +489,12 @@ static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer dat return vw->vt->tools[vw->vt->active_tool].ti.key_press(vl, event, vw->vt->tools[vw->vt->active_tool].state); } - // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer - if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) { - return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state ); + // Ensure called only on window tools (i.e. not on any of the Layer tools since the layer is NULL) + if ( vw->current_tool < TOOL_LAYER ) { + // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer + if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) { + return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state ); + } } /* Restore Main Menu via Escape key if the user has hidden it */