8000 Fix crash in early window raise in gtk3. · matplotlib/matplotlib@1335c6c · GitHub
[go: up one dir, main page]

Skip to content

Commit 1335c6c

Browse files
committed
Fix crash in early window raise in gtk3.
Repro: import matplotlib as 8000 mpl import matplotlib.pyplot as plt mpl.use('GTK3Agg') plt.figure().canvas.mpl_connect('resize_event', lambda e: plt.pause(1)) plt.show()
1 parent fba5d15 commit 1335c6c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,14 @@ def show(self):
392392
self.window.show()
393393
self.canvas.draw()
394394
if mpl.rcParams['figure.raise_window']:
395-
self.window.present()
395+
if self.window.get_window():
396+
self.window.present()
397+
else:
398+
# If this is called by a callback early during init,
399+
# self.window (a GtkWindow) may not have an associated
400+
# low-level GdkWindow (self.window.get_window()) yet, and
401+
# present() would crash.
402+
_api.warn_external("Cannot raise window yet to be setup")
396403

397404
def full_screen_toggle(self):
398405
self._full_screen_flag = not self._full_screen_flag

0 commit comments

Comments
 (0)
0