# HG changeset patch # User Laurent Bessard # Date 1380612242 -7200 # Node ID 204ef2daa33cc00e140fdcb42c9adb5f7be88e71 # Parent 1054cb01b523d43b41ddc95fb33a31bb8b0ccb10 Fixed bug with Copy/Paste function instance block when previously edited diff -r 1054cb01b523 -r 204ef2daa33c PLCControler.py --- a/PLCControler.py Sun Sep 29 21:37:13 2013 +0200 +++ b/PLCControler.py Tue Oct 01 09:24:02 2013 +0200 @@ -2220,9 +2220,10 @@ element.addinstance(instance) instance_type = instance.getLocalTag() if instance_type == "block": + blocktype = instance.gettypeName() + blocktype_infos = self.GetBlockType(blocktype) blockname = instance.getinstanceName() - if blockname is not None: - blocktype = instance.gettypeName() + if blocktype_infos["type"] != "function" and blockname is not None: if element_type == "function": return _("FunctionBlock \"%s\" can't be pasted in a Function!!!")%blocktype blockname = self.GenerateNewName(tagname, @@ -2448,7 +2449,10 @@ self.ChangeEditedElementPouVar(tagname, old_type, old_name, new_type, new_name) for param, value in infos.items(): if param == "name": - block.setinstanceName(value) + if value != "": + block.setinstanceName(value) + else: + block.attrib.pop("instanceName", None) elif param == "type": block.settypeName(value) elif param == "executionOrder" and block.getexecutionOrderId() != value: