Fixed misuse of GridCellEditor in DurationCellEditor, potentially leading to crash on windows.
authorEdouard Tisserant
Mon, 29 Mar 2021 15:46:02 +0200
changeset 2734 3768af52835a
parent 2733 244598a6a0d6
child 2735 732d112dd902
Fixed misuse of GridCellEditor in DurationCellEditor, potentially leading to crash on windows.
controls/DurationCellEditor.py
--- a/controls/DurationCellEditor.py	Tue Mar 23 05:08:51 2021 +0100
+++ 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,