Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
authorLaurent Bessard
Wed, 29 May 2013 11:10:19 +0200
changeset 1189 93a4431a0cd8
parent 1188 63afb5833bd8
child 1190 410b519abd66
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
controls/PouInstanceVariablesPanel.py
--- a/controls/PouInstanceVariablesPanel.py	Wed May 29 09:42:25 2013 +0200
+++ b/controls/PouInstanceVariablesPanel.py	Wed May 29 11:10:19 2013 +0200
@@ -322,19 +322,25 @@
         event.Skip()
         
     def OnVariablesListItemActivated(self, event):
-        if self.InstanceChoice.GetSelection() != -1:
-            instance_path = self.InstanceChoice.GetStringSelection()
-            selected_item = event.GetItem()
-            if selected_item is not None and selected_item.IsOk():
-                item_infos = self.VariablesList.GetPyData(selected_item)
-                if item_infos is not None and item_infos["class"] not in ITEMS_VARIABLE:
-                    if item_infos["class"] == ITEM_RESOURCE:
+        selected_item = event.GetItem()
+        if selected_item is not None and selected_item.IsOk():
+            item_infos = self.VariablesList.GetPyData(selected_item)
+            if item_infos is not None and item_infos["class"] not in ITEMS_VARIABLE:
+                instance_path = self.InstanceChoice.GetStringSelection()
+                if item_infos["class"] == ITEM_RESOURCE:
+                    if instance_path != "":
                         tagname = self.Controller.ComputeConfigurationResourceName(
                                        instance_path, 
                                        item_infos["name"])
                     else:
-                        tagname = self.Controller.ComputePouName(item_infos["type"])
-                    item_path = "%s.%s" % (instance_path, item_infos["name"])
+                        tagname = None
+                else:
+                    tagname = self.Controller.ComputePouName(item_infos["type"])
+                if tagname is not None:
+                    if instance_path != "":
+                        item_path = "%s.%s" % (instance_path, item_infos["name"])
+                    else:
+                        item_path = None
                     wx.CallAfter(self.SetPouType, tagname, item_path)
                     wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname)
         event.Skip()