don't allow empty dimension for ARRAY types
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 11 Aug 2017 15:18:19 +0300
changeset 1726 d51af006fa6b
parent 1725 f8e4650619f7
child 1727 865e157c6474
child 1730 64d8f52bc8c8
don't allow empty dimension for ARRAY types
dialogs/ArrayTypeDialog.py
--- a/dialogs/ArrayTypeDialog.py	Wed Aug 09 14:34:28 2017 +0300
+++ b/dialogs/ArrayTypeDialog.py	Fri Aug 11 15:18:19 2017 +0300
@@ -90,21 +90,28 @@
         self.Fit()
         
     def GetDimensions(self):
+        message = None
         dimensions_list = []
-        for dimensions in self.Dimensions.GetStrings():
+        dimension_strings = self.Dimensions.GetStrings()
+        if len(dimension_strings) == 0:
+            message = _("Empty dimension isn't allowed.")
+
+        for dimensions in dimension_strings:
             result = DIMENSION_MODEL.match(dimensions)
             if result is None:
-                message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
-                message.ShowModal()
-                message.Destroy()
-                return None
+                message = _("\"%s\" value isn't a valid array dimension!")%dimensions
+                break
             bounds = result.groups()
             if int(bounds[0]) >= int(bounds[1]):
-                message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
-                message.ShowModal()
-                message.Destroy()
-                return None
+                message = _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.")%dimensions
+                break
             dimensions_list.append(bounds)
+
+        if message is not None:
+            dlg = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+            dlg.ShowModal()
+            dlg.Destroy()
+            return None
         return dimensions_list
     
     def OnDimensionsChanged(self, event):