Removing memory leak while closing PluginsRoot
authorlaurent
Fri, 02 Oct 2009 11:25:35 +0200
changeset 403 ae4a85291441
parent 402 984e238e63d0
child 404 dbe88e319bdf
Removing memory leak while closing PluginsRoot
Beremiz.py
plugger.py
--- a/Beremiz.py	Sat Sep 26 18:44:25 2009 +0200
+++ b/Beremiz.py	Fri Oct 02 11:25:35 2009 +0200
@@ -1273,6 +1273,8 @@
     def ResetView(self):
         IDEFrame.ResetView(self)
         self.PluginInfos = {}
+        if self.PluginRoot is not None:
+            self.PluginRoot.CloseProject()
         self.PluginRoot = None
         self.Log.flush()
         self.DebugVariablePanel.SetDataProducer(None)
--- a/plugger.py	Sat Sep 26 18:44:25 2009 +0200
+++ b/plugger.py	Fri Oct 02 11:25:35 2009 +0200
@@ -560,7 +560,7 @@
                     _self.PlugRequestSave()
                     #just created, must be saved
                     _self.ChangesToSave = True
-            
+                
             def _getBuildPath(_self):
                 return self._getBuildPath()
             
@@ -570,7 +570,12 @@
         PluggedChildsWithSameClass.append(newPluginOpj)
         
         return newPluginOpj
-            
+    
+    def ClearPluggedChilds(self):
+        for child in self.IterChilds():
+            child.ClearPluggedChilds()
+        self.PluggedChilds = {}
+    
     def LoadSTLibrary(self):
         # Get library blocks if plcopen library exist
         library_path = self.PluginLibraryFilePath()
@@ -881,6 +886,10 @@
 
         return None
     
+    def CloseProject(self):
+        self.ClearPluggedChilds()
+        self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer)
+    
     def SaveProject(self):
         if not self.SaveXMLFile():
             self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))