Skip to content

Commit 0f58558

Browse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #19671: Fix crash in early window raise in gtk3.
1 parent 3953935 commit 0f58558

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)