mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-02 13:56:39 +00:00
Fixes memory leaks on {re,un}do state mutation & resize-related operations.
MiRCARTCanvas.py:__del__(): delete canvasMap w/ clear(). MiRCARTCanvasBackend.py:resize(): delete old canvasBitmap w/ Destroy(). MiRCARTCanvasJournal.py:reset{Cursor,Undo}(): delete patches{Cursor,Undo} w/ clear(). MiRCARTCanvasJournal.py:__del__(): provided explicitly to call reset{Cursor,Undo}(). MiRCARTFrame.py:__del__(): provided explicitly to delete panelCanvas.
This commit is contained in:
parent
579dd858ba
commit
c6ab27c08c
@ -181,8 +181,14 @@ class MiRCARTCanvas(wx.Panel):
|
||||
self.parentFrame.onCanvasUpdate(size=newCanvasSize, undoLevel=-1)
|
||||
# }}}
|
||||
|
||||
# {{{ __del__(self): destructor method
|
||||
def __del__(self):
|
||||
if self.canvasMap != None:
|
||||
self.canvasMap.clear(); self.canvasMap = None;
|
||||
# }}}
|
||||
|
||||
#
|
||||
# _init__(self, parent, parentFrame, defaultCanvasPos, defaultCanvasSize, defaultCellSize): initialisation method
|
||||
# __init__(self, parent, parentFrame, defaultCanvasPos, defaultCanvasSize, defaultCellSize): initialisation method
|
||||
def __init__(self, parent, parentFrame, defaultCanvasPos, defaultCanvasSize, defaultCellSize):
|
||||
super().__init__(parent, pos=defaultCanvasPos, \
|
||||
size=[w*h for w,h in zip(defaultCanvasSize, defaultCellSize)])
|
||||
|
@ -141,7 +141,8 @@ class MiRCARTCanvasBackend():
|
||||
newBitmap = wx.Bitmap(winSize)
|
||||
newDc.SelectObject(newBitmap)
|
||||
newDc.Blit(0, 0, *self.canvasBitmap.GetSize(), oldDc, 0, 0)
|
||||
self.canvasBitmap = newBitmap
|
||||
oldDc.SelectObject(wx.NullBitmap)
|
||||
self.canvasBitmap.Destroy(); self.canvasBitmap = newBitmap;
|
||||
self.canvasSize = canvasSize; self.cellSize = cellSize;
|
||||
self._font = wx.Font( \
|
||||
8, \
|
||||
@ -166,7 +167,7 @@ class MiRCARTCanvasBackend():
|
||||
# }}}
|
||||
|
||||
#
|
||||
# _init__(self, canvasSize, cellSize): initialisation method
|
||||
# __init__(self, canvasSize, cellSize): initialisation method
|
||||
def __init__(self, canvasSize, cellSize):
|
||||
self._initBrushesAndPens()
|
||||
self.reset(canvasSize, cellSize)
|
||||
|
@ -68,10 +68,14 @@ class MiRCARTCanvasJournal():
|
||||
# }}}
|
||||
# {{{ resetCursor(self): XXX
|
||||
def resetCursor(self):
|
||||
if self.patchesCursor != None:
|
||||
self.patchesCursor.clear()
|
||||
self.patchesCursor = []
|
||||
# }}}
|
||||
# {{{ resetUndo(self): XXX
|
||||
def resetUndo(self):
|
||||
if self.patchesUndo != None:
|
||||
self.patchesUndo.clear()
|
||||
self.patchesUndo = [None]; self.patchesUndoLevel = 0;
|
||||
# }}}
|
||||
# {{{ updateCurrentDeltas(self, undoPatches, redoPatches): XXX
|
||||
@ -80,6 +84,11 @@ class MiRCARTCanvasJournal():
|
||||
self.patchesUndo[0][1].append(redoPatches)
|
||||
# }}}
|
||||
|
||||
# {{{ __del__(self): destructor method
|
||||
def __del__(self):
|
||||
self.resetCursor(); self.resetUndo();
|
||||
# }}}
|
||||
|
||||
#
|
||||
# __init__(self): initialisation method
|
||||
def __init__(self):
|
||||
|
@ -227,6 +227,12 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
||||
toolBar.EnableTool(self.CID_REDO[0], False)
|
||||
# }}}
|
||||
|
||||
# {{{ __del__(self): destructor method
|
||||
def __del__(self):
|
||||
if self.panelCanvas != None:
|
||||
del self.panelCanvas; self.panelCanvas = None;
|
||||
# }}}
|
||||
|
||||
#
|
||||
# __init__(self, parent, appSize=(840, 630), defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14)): initialisation method
|
||||
def __init__(self, parent, appSize=(840, 630), defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14)):
|
||||
|
Loading…
Reference in New Issue
Block a user