Fixed misuse of GridCellEditor in DurationCellEditor, potentially leading to crash on windows. svghmi
authorEdouard Tisserant
Mon, 29 Mar 2021 15:46:02 +0200
branchsvghmi
changeset 3209 a5bca0a5eaf5
parent 3208 b5330d76e225
child 3210 0ddefd20ca2b
Fixed misuse of GridCellEditor in DurationCellEditor, potentially leading to crash on windows.
controls/DurationCellEditor.py
--- a/controls/DurationCellEditor.py	Mon Mar 29 14:35:45 2021 +0200
+++ b/controls/DurationCellEditor.py	Mon Mar 29 15:46:02 2021 +0200
@@ -122,21 +122,18 @@
         self.CellControl.SetValue(self.Table.GetValueByName(row, self.Colname))
         self.CellControl.SetFocus()
 
-    def EndEditInternal(self, row, col, grid, old_duration):
-        duration = self.CellControl.GetValue()
-        changed = duration != old_duration
+    def EndEdit(self, row, col, grid, oldval):
+        value = self.CellControl.GetValue()
+        changed = value != oldval
         if changed:
-            self.Table.SetValueByName(row, self.Colname, duration)
+            return value
+        else:
+            return None
+
+    def ApplyEdit(self, row, col, grid):
+        value = self.CellControl.GetValue()
+        self.Table.SetValueByName(row, self.Colname, value)
         self.CellControl.Disable()
-        return changed
-
-    if wx.VERSION >= (3, 0, 0):
-        def EndEdit(self, row, col, grid, oldval):
-            return self.EndEditInternal(row, col, grid, oldval)
-    else:
-        def EndEdit(self, row, col, grid):
-            oldval = self.Table.GetValueByName(row, self.Colname)
-            return self.EndEditInternal(row, col, grid, oldval)
 
     def SetSize(self, rect):
         self.CellControl.SetDimensions(rect.x + 1, rect.y,