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

Skip to content

Commit 5dd147e

Browse files
committed
Prevent memory leak of FileChooserDialog
svn path=/trunk/matplotlib/; revision=3449
1 parent 1faa2d6 commit 5dd147e

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/matplotlib/backends/backend_gtk.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ def __init__(self, canvas, window):
792792

793793
def destroy(*args):
794794
self.fileselect.destroy()
795+
del self.fileselect
795796
self.connect("destroy", destroy)
796797

797798
def _create_toolitems_2_4(self):
@@ -1047,26 +1048,25 @@ def __init__ (self,
10471048
buttons)
10481049
self.set_default_response (gtk.RESPONSE_OK)
10491050

1050-
if path: self.path = path
1051-
else: self.path = os.getcwd() + os.sep
1051+
if not path: path = os.getcwd() + os.sep
10521052

10531053
# create an extra widget to list supported image formats
1054-
self.set_current_folder (self.path)
1054+
self.set_current_folder (path)
10551055
self.set_current_name ('image.' + IMAGE_FORMAT_DEFAULT)
10561056

10571057
hbox = gtk.HBox (spacing=10)
10581058
hbox.pack_start (gtk.Label ("Image Format:"), expand=False)
10591059

10601060
liststore = gtk.ListStore(gobject.TYPE_STRING)
1061-
self.cbox = gtk.ComboBox(liststore)
1061+
cbox = gtk.ComboBox(liststore)
10621062
cell = gtk.CellRendererText()
1063-
self.cbox.pack_start(cell, True)
1064-
self.cbox.add_attribute(cell, 'text', 0)
1065-
hbox.pack_start (self.cbox)
1063+
cbox.pack_start(cell, True)
1064+
cbox.add_attribute(cell, 'text', 0)
1065+
hbox.pack_start (cbox)
10661066

10671067
for item in IMAGE_FORMAT:
1068-
self.cbox.append_text (item)
1069-
self.cbox.set_active (IMAGE_FORMAT.index (IMAGE_FORMAT_DEFAULT))
1068+
cbox.append_text (item)
1069+
cbox.set_active (IMAGE_FORMAT.index (IMAGE_FORMAT_DEFAULT))
10701070

10711071
def cb_cbox_changed (cbox, data=None):
10721072
"""File extension changed"""
@@ -1081,7 +1081,7 @@ def cb_cbox_changed (cbox, data=None):
10811081
filename = filename.rstrip('.') + '.' + new_ext
10821082

10831083
self.set_current_name (filename)
1084-
self.cbox.connect ("changed", cb_cbox_changed)
1084+
cbox.connect ("changed", cb_cbox_changed)
10851085

10861086
hbox.show_all()
10871087
self.set_extra_widget(hbox)

0 commit comments

Comments
 (0)