]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Prevent obscure crash on key press when layer is not selected but create track tool...
[andy/viking.git] / src / vikwindow.c
index ef4e2bc67938bd00da1d1291d1a8156ef8ac02f8..4818ee171b03bd1eae90949892255afc5fcaabd6 100644 (file)
@@ -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 */