Fixed bug when adding a variable in Variable Panel and selected variable can't be edited (generally a FB)
authorLaurent Bessard
Mon, 27 May 2013 09:24:39 +0200
changeset 1175 01842255c9ff
parent 1174 9cc1a3fa9619
child 1176 f4b434672204
Fixed bug when adding a variable in Variable Panel and selected variable can't be edited (generally a FB)
controls/VariablePanel.py
--- a/controls/VariablePanel.py	Fri May 24 18:29:02 2013 +0200
+++ b/controls/VariablePanel.py	Mon May 27 09:24:39 2013 +0200
@@ -523,6 +523,7 @@
         def _AddVariable(new_row):
             if new_row > 0:
                 row_content = self.Values[new_row - 1].copy()
+                
                 result = VARIABLE_NAME_SUFFIX_MODEL.search(row_content["Name"])
                 if result is not None:
                     name = row_content["Name"][:result.start(1)]
@@ -534,14 +535,21 @@
                 else:
                     name = row_content["Name"]
                     start_idx = 0
-                row_content["Name"] = self.Controler.GenerateNewName(
-                    self.TagName, None, name + "%d", start_idx)
+            else:
+                name = ""
+                
+            if row_content is not None and row_content["Edit"]: 
+                row_content = self.Values[new_row - 1].copy()
             else:
                 row_content = self.DefaultValue.copy()
                 if self.Filter in self.DefaultTypes:
                     row_content["Class"] = self.DefaultTypes[self.Filter]
                 else:
                     row_content["Class"] = self.Filter
+            
+            row_content["Name"] = self.Controler.GenerateNewName(
+                    self.TagName, None, name + "%d", start_idx)
+            
             if self.Filter == "All" and len(self.Values) > 0:
                 self.Values.insert(new_row, row_content)
             else: