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

Skip to content

Commit 0e4cd88

Browse files
committed
Fix crash in early window raise in gtk3.
Repro: import matplotlib as 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 0e4cd88

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ def show(self):
391391
# show the figure window
392392
self.window.show()
393393
self.canvas.draw()
394-
if mpl.rcParams['figure.raise_window']:
394+
# If this is called by a callback early during init, self.window (a
395+
# GtkWindow) may not have an associated low-level GdkWindow
396+
# (self.window.get_window()) yet, and present() would crash -- hence
397+
# the additional check.
398+
if mpl.rcParams['figure.raise_window'] and self.window.get_window():
395399
self.window.present()
396400

397401
def full_screen_toggle(self):

0 commit comments

Comments
 (0)
0