From c96364146f28dbe84fcf11d326bf8c4518dd3698 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Fri, 18 Sep 2020 11:34:47 -0400
Subject: [PATCH] Fixed crasher when pressing a key inside non-canvas window

* Fun to know that canvas_key is called even when you are not inside a canvas...
---
 pd/src/g_editor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 38d6ddf15..f3c746bb1 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -5478,7 +5478,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
     // now broadcast key press to key et al. objects
     // ico@vt.edu 20200918: only do so if we do not have an object
     // that has grabbed the keyboard, such as gatom or iemgui numbox
-    if (!x->gl_editor->e_keyfn)
+    if (!x || !x->gl_editor || !x->gl_editor->e_keyfn)
     {
         if (!autorepeat)
         {
-- 
GitLab