# HG changeset patch
# User laurent
# Date 1347376931 -7200
# Node ID be669f4c51c474ee51c9d2caed5108fbd8ecfc18
# Parent  c6ed7b933617a2fe702a351c798ae0cea8ccc7cd
Fix bug in SFC function block declarations from transition and action not removed when transition or action is deleted

diff -r c6ed7b933617 -r be669f4c51c4 plcopen/plcopen.py
--- a/plcopen/plcopen.py	Tue Sep 11 16:35:11 2012 +0200
+++ b/plcopen/plcopen.py	Tue Sep 11 17:22:11 2012 +0200
@@ -1435,6 +1435,11 @@
             removed = False
             while i < len(transitions) and not removed:
                 if transitions[i].getname() == name:
+                    if transitions[i].getbodyType() in ["FBD", "LD", "SFC"]:
+                        for instance in transitions[i].getinstances():
+                            if isinstance(instance, PLCOpenClasses["fbdObjects_block"]):
+                                self.removepouVar(instance.gettypeName(), 
+                                                  instance.getinstanceName())
                     transitions.pop(i)
                     removed = True
                 i += 1
@@ -1465,7 +1470,7 @@
             return self.actions.getaction()
         return []
     setattr(cls, "getactionList", getactionList)
-        
+    
     def removeaction(self, name):
         if self.actions:
             actions = self.actions.getaction()
@@ -1473,6 +1478,11 @@
             removed = False
             while i < len(actions) and not removed:
                 if actions[i].getname() == name:
+                    if actions[i].getbodyType() in ["FBD", "LD", "SFC"]:
+                        for instance in actions[i].getinstances():
+                            if isinstance(instance, PLCOpenClasses["fbdObjects_block"]):
+                                self.removepouVar(instance.gettypeName(), 
+                                                  instance.getinstanceName())
                     actions.pop(i)
                     removed = True
                 i += 1