Skip to content

Commit 18204b0

Browse files
committed
wx/wxagg emmleak fixes
svn path=/trunk/matplotlib/; revision=868
1 parent 25dfebe commit 18204b0

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
New entries should be added at the top
22

3+
2005-01-17 Cleaned up Destroy handling in wx reducing memleak/fig from
4+
approx 800k to approx 6k- JDH
5+
36
2005-01-17 Added kappa to latex_to_bakoma - JDH
47

58
2005-01-15 Support arbitrary colorbar axes and horizontal colorbars - JDH

lib/matplotlib/backends/backend_wx.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ def __init__(self, parent, id, figure):
715715

716716
self.Printer_Init()
717717

718+
def Destroy(self, *args, **kwargs):
719+
wxPanel.Destroy(self, *args, **kwargs)
720+
721+
718722
def Copy_to_Clipboard(self, event=None):
719723
"copy bitmap of canvas to system clipboard"
720724
bmp_obj = wx.BitmapDataObject()
@@ -1240,7 +1244,12 @@ def _onClose(self, evt):
12401244
def GetToolBar(self):
12411245
"""Override wxFrame::GetToolBar as we don't have managed toolbar"""
12421246
return self.toolbar
1243-
1247+
1248+
def Destroy(self, *args, **kwargs):
1249+
wxFrame.Destroy(self, *args, **kwargs)
1250+
if self.toolbar is not None:
1251+
self.toolbar.Destroy()
1252+
12441253
class FigureManagerWx(FigureManagerBase):
12451254
"""
12461255
This class contains the FigureCanvas and GUI frame
@@ -1270,6 +1279,8 @@ def notify_axes_change(fig):
12701279
def destroy(self, *args):
12711280
DEBUG_MSG("destroy()", 1, self)
12721281
self.frame.Destroy()
1282+
self.canvas.Destroy()
1283+
#if self.tb is not None: self.tb.Destroy()
12731284
import wx
12741285
#wx.GetApp().ProcessIdle()
12751286
wx.WakeUpIdle()

lib/matplotlib/backends/backend_wxagg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def draw(self):
4949
Render the figure using agg
5050
"""
5151
DEBUG_MSG("draw()", 1, self)
52-
5352
FigureCanvasAgg.draw(self)
5453
s = self.tostring_rgb()
5554
w = int(self.renderer.width)

unit/memleak_hawaii3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import matplotlib
55
matplotlib.interactive(True)
66
#matplotlib.use('Cairo')
7-
matplotlib.use('TkAgg')
7+
matplotlib.use('WXAgg')
88
from pylab import *
99

1010

@@ -36,6 +36,7 @@ def report_memory(i):
3636
pcolor(10*rand(50,50))
3737
ion()
3838
draw()
39+
3940
#ioff()
4041
#savefig('tmp%d' % i, dpi = 75)
4142
#fd = file('tmp%d' % i, 'wb')

0 commit comments

Comments
 (0)