Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a150bc9

Browse files
committed
Fix cyclical reference leak in Qt4 backend. (Cycle created by a signal).
svn path=/trunk/matplotlib/; revision=3454
1 parent a247ebf commit a150bc9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/matplotlib/backends/backend_qt4.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ def resize(self, width, height):
247247
def destroy( self, *args ):
248248
if self.window._destroying: return
249249
self.window._destroying = True
250+
QtCore.QObject.disconnect( self.window, QtCore.SIGNAL( 'destroyed()' ),
251+
self._widgetclosed )
250252
if DEBUG: print "destroy figure manager"
251253
self.window.close()
252254

@@ -280,6 +282,7 @@ def __init__(self, canvas, parent):
280282

281283
def _init_toolbar( self ):
282284
basedir = os.path.join(matplotlib.rcParams[ 'datapath' ],'images')
285+
self.buttons = {}
283286

284287
for text, tooltip_text, image_file, callback in self.toolitems:
285288
if text == None:
@@ -292,6 +295,7 @@ def _init_toolbar( self ):
292295

293296
button = QtGui.QPushButton( QtGui.QIcon( image ), "", self )
294297
button.setToolTip(tooltip_text)
298+
self.buttons[ text ] = button
295299

296300
# The automatic layout doesn't look that good - it's too close
297301
# to the images so add a margin around it.

0 commit comments

Comments
 (0)