From 40425149559f3ad808c78d78a19212cc3ab6e9e6 Mon Sep 17 00:00:00 2001 From: John Hunter Date: Sun, 26 Feb 2012 07:07:38 -0600 Subject: [PATCH] fix qt close event bug --- lib/matplotlib/backends/backend_qt4.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 279a3c205af7..623b245ef7da 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -138,8 +138,17 @@ def __init__( self, figure ): w,h = self.get_width_height() self.resize( w, h ) + # JDH: Note the commented out code below does not work as + # expected, because according to Pierre Raybaut, The reason is + # that PyQt fails (silently) to call a method of this object + # just before detroying it. Using a lambda function will work, + # exactly the same as using a function (which is not bound to + # the object to be destroyed). + # + #QtCore.QObject.connect(self, QtCore.SIGNAL('destroyed()'), + # self.close_event) QtCore.QObject.connect(self, QtCore.SIGNAL('destroyed()'), - self.close_event) + lambda: self.close_event()) def __timerEvent(self, event): # hide until we can test and fix