Fixed bug when adding and removing function block in graphic viewer. In some cases, the associated variable could stay in the variable panel.
authorLaurent Bessard
Fri, 25 Oct 2013 09:57:36 +0200
changeset 1371 3c55c99b10ab
parent 1370 ee795a8d4404
child 1372 ef26fcb7f5d4
Fixed bug when adding and removing function block in graphic viewer. In some cases, the associated variable could stay in the variable panel.
plcopen/plcopen.py
--- a/plcopen/plcopen.py	Thu Oct 17 23:27:23 2013 +0200
+++ b/plcopen/plcopen.py	Fri Oct 25 09:57:36 2013 +0200
@@ -1197,7 +1197,7 @@
         if len(content) == 0:
             varlist = PLCOpenParser.CreateElement(var_class, "interface")
             self.interface.setcontent([varlist])
-        elif content[-1] != var_class:
+        elif content[-1].getLocalTag() != var_class:
             varlist = PLCOpenParser.CreateElement(var_class, "interface")
             content[-1].addnext(varlist)
         else:
@@ -1242,10 +1242,9 @@
                         vartype_content = var.gettype().getcontent()
                         if vartype_content.getLocalTag() == "derived" and vartype_content.getname() == var_type:
                             varlist.remove(var)
+                            if len(varlist.getvariable()) == 0:
+                                self.interface.remove(varlist)
                             break
-                if len(varlist.getvariable()) == 0:
-                    content.remove(varlist)
-                    break
     setattr(cls, "removepouVar", removepouVar)
     
     def hasblock(self, name=None, block_type=None):