changeset 20057:5bd3216748fc

PopupMenuControl: check value is integer (Bug #44678) * libgui/graphics/PopupMenuControl.cc: (PopupMenuControl::update): check value is integer and warn if not
author John Donoghue
date Thu, 02 Apr 2015 16:51:35 -0400
parents e70df1ff58b7
children 6babcfbe1a0a
files libgui/graphics/PopupMenuControl.cc
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/PopupMenuControl.cc	Thu Apr 02 14:50:17 2015 -0400
+++ b/libgui/graphics/PopupMenuControl.cc	Thu Apr 02 16:51:35 2015 -0400
@@ -105,15 +105,22 @@
 
           if (value.numel () > 0)
             {
-              int newIndex = int (value(0)) - 1;
-
-              if (newIndex >= 0 && newIndex < box->count ())
+              if (value(0) !=  static_cast<int>(value(0)))
                 {
-                  if (newIndex != box->currentIndex ())
-                    box->setCurrentIndex (newIndex);
+                warning ("popupmenu value should be integer");
                 }
               else
-                warning ("popupmenu value not within valid display range");
+                {
+                  int newIndex = int (value(0)) - 1;
+
+                  if (newIndex >= 0 && newIndex < box->count ())
+                    {
+                      if (newIndex != box->currentIndex ())
+                        box->setCurrentIndex (newIndex);
+                    }
+                  else
+                    warning ("popupmenu value not within valid display range");
+                }
             }
         }
       m_blockUpdate = false;