From 6cf9b31a18c863445df24f2b565705cd916d2cfe Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 16 Oct 2017 11:32:13 +1000 Subject: [PATCH 27/30] MouseMap: if the old highlight is None, don't try to redraw When pressing a button and moving out of the button area with the button held down, we get two leave events - once when actually leaving the button and once more when the button press is released later. On the second call, the old highlight is already None, causing a crash when we're trying to get SVG information about it. Fixes #185 --- piper/mousemap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/piper/mousemap.py b/piper/mousemap.py index 0d8fbb5..716bd64 100644 --- a/piper/mousemap.py +++ b/piper/mousemap.py @@ -314,6 +314,10 @@ class MouseMap(Gtk.Container): def _on_leave(self, widget, event): # Restores the device SVG to its original state. old_highlight = self._highlight_element + + if old_highlight is None: + return + self._highlight_element = None self._redraw_svg_element(old_highlight) -- 2.16.1