# HG changeset patch
# User laurent
# Date 1254475535 -7200
# Node ID ae4a8529144190b30815b517dba811b50b55e26a
# Parent  984e238e63d0e68d359f0e92ba008f43ac8a3d46
Removing memory leak while closing PluginsRoot

diff -r 984e238e63d0 -r ae4a85291441 Beremiz.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)
diff -r 984e238e63d0 -r ae4a85291441 plugger.py
--- 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'))