Skip to content

Commit 5aa9374

Browse files
committed
Fix segfault in Tk backend.
svn path=/trunk/matplotlib/; revision=3508
1 parent 17dd254 commit 5aa9374

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,7 @@ def destroy(*args):
343343
self.window = None
344344
Gcf.destroy(self._num)
345345

346-
#if not self._shown: self.window.bind("<Destroy>", destroy)
347-
if not self._shown: self.canvas._tkcanvas.bind("<Destroy>")
346+
if not self._shown: self.canvas._tkcanvas.bind("<Destroy>", destroy)
348347
_focus = windowing.FocusManager()
349348
if not self._shown:
350349
self.window.deiconify()

src/_tkagg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
5353

5454
long mode;
5555
long nval;
56+
if (Tk_MainWindow(interp) == NULL) {
57+
// Will throw a _tkinter.TclError with "this isn't a Tk application"
58+
return TCL_ERROR;
59+
}
60+
5661
if (argc != 5) {
5762
Tcl_AppendResult(interp, "usage: ", argv[0],
5863
" destPhoto srcImage", (char *) NULL);

0 commit comments

Comments
 (0)