# HG changeset patch
# User Edouard Tisserant
# Date 1617025562 -7200
# Node ID 3768af52835a1d6c748728dd71c80684dc760913
# Parent  244598a6a0d66c8a042a08a6285c22a2a63aebce
Fixed misuse of GridCellEditor in DurationCellEditor, potentially leading to crash on windows.

diff -r 244598a6a0d6 -r 3768af52835a 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,