Fix for bug [ 1098263 ] wx.lib.ogl control points leak

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-01-12 03:48:06 +00:00
parent a6fb8636e5
commit 3dd9536f2e
2 changed files with 20 additions and 17 deletions

View File

@@ -19,7 +19,6 @@ from _oglmisc import *
DragOffsetX = 0.0 DragOffsetX = 0.0
DragOffsetY = 0.0 DragOffsetY = 0.0
def OGLInitialize(): def OGLInitialize():
global WhiteBackgroundPen, WhiteBackgroundBrush, TransparentPen global WhiteBackgroundPen, WhiteBackgroundBrush, TransparentPen
global BlackForegroundPen, NormalFont global BlackForegroundPen, NormalFont
@@ -83,6 +82,10 @@ class ShapeEvtHandler(object):
def GetPreviousHandler(self): def GetPreviousHandler(self):
return self._previousHandler return self._previousHandler
def OnDelete(self):
if self!=self.GetShape():
del self
def OnDraw(self, dc): def OnDraw(self, dc):
if self._previousHandler: if self._previousHandler:
self._previousHandler.OnDraw(dc) self._previousHandler.OnDraw(dc)
@@ -284,7 +287,7 @@ class Shape(ShapeEvtHandler):
def GetClassName(self): def GetClassName(self):
return str(self.__class__).split(".")[-1][:-2] return str(self.__class__).split(".")[-1][:-2]
def __del__(self): def Delete(self):
if self._parent: if self._parent:
i = self._parent.GetChildren().index(self) i = self._parent.GetChildren().index(self)
self._parent.GetChildren(i).remove(self) self._parent.GetChildren(i).remove(self)
@@ -293,10 +296,16 @@ class Shape(ShapeEvtHandler):
self.ClearRegions() self.ClearRegions()
self.ClearAttachments() self.ClearAttachments()
self._handlerShape = None
if self._canvas: if self._canvas:
self._canvas.RemoveShape(self) self.RemoveFromCanvas(self._canvas)
self.GetEventHandler().OnDelete() self.GetEventHandler().OnDelete()
self._eventHandler = None
def __del__(self):
ShapeEvtHandler.__del__(self)
def Draggable(self): def Draggable(self):
"""TRUE if the shape may be dragged by the user.""" """TRUE if the shape may be dragged by the user."""
@@ -416,6 +425,8 @@ class Shape(ShapeEvtHandler):
"""Remove the shape from the canvas.""" """Remove the shape from the canvas."""
if self.Selected(): if self.Selected():
self.Select(False) self.Select(False)
self._canvas = None
theCanvas.RemoveShape(self) theCanvas.RemoveShape(self)
for object in self._children: for object in self._children:
object.RemoveFromCanvas(theCanvas) object.RemoveFromCanvas(theCanvas)
@@ -1372,11 +1383,11 @@ class Shape(ShapeEvtHandler):
Does not redraw the shape. Does not redraw the shape.
""" """
for control in self._controlPoints: for control in self._controlPoints[:]:
if dc: if dc:
control.GetEventHandler().OnErase(dc) control.GetEventHandler().OnErase(dc)
self._canvas.RemoveShape(control) control.Delete()
del control self._controlPoints.remove(control)
self._controlPoints = [] self._controlPoints = []
# Children of divisions are contained objects, # Children of divisions are contained objects,
@@ -1540,11 +1551,6 @@ class Shape(ShapeEvtHandler):
return True return True
return False return False
# Clears points from a list of wxRealPoints, and clears list
# Useless in python? /pi
def ClearPointList(self, list):
list = []
# Assuming the attachment lies along a vertical or horizontal line, # Assuming the attachment lies along a vertical or horizontal line,
# calculate the position on that point. # calculate the position on that point.
def CalcSimpleAttachment(self, pt1, pt2, nth, noArcs, line): def CalcSimpleAttachment(self, pt1, pt2, nth, noArcs, line):

View File

@@ -220,7 +220,6 @@ class LineShape(Shape):
def __del__(self): def __del__(self):
if self._lineControlPoints: if self._lineControlPoints:
self.ClearPointList(self._lineControlPoints)
self._lineControlPoints = [] self._lineControlPoints = []
for i in range(3): for i in range(3):
if self._labelObjects[i]: if self._labelObjects[i]:
@@ -289,8 +288,6 @@ class LineShape(Shape):
def MakeLineControlPoints(self, n): def MakeLineControlPoints(self, n):
"""Make a given number of control points (minimum of two).""" """Make a given number of control points (minimum of two)."""
if self._lineControlPoints:
self.ClearPointList(self._lineControlPoints)
self._lineControlPoints = [] self._lineControlPoints = []
for _ in range(n): for _ in range(n):