]> git.mxchange.org Git - flightgear.git/commitdiff
puList.cxx: _list_box->getIntegerValue() returns -1 as long as no list
authormfranz <mfranz>
Wed, 22 Mar 2006 10:56:49 +0000 (10:56 +0000)
committermfranz <mfranz>
Wed, 22 Mar 2006 10:56:49 +0000 (10:56 +0000)
  entry was selected. Return 0 in this case, not an invalid string address
  (causing segfaults).
dialogs.cxx: don't set property if no list entry was chosen.

src/GUI/dialog.cxx
src/GUI/puList.cxx

index 6d9dafe19a742a2237fc1855f40fe22e52c5a76e..d09d572e98168a6b1fcbce6b5e9e391fb49a1ce9 100644 (file)
@@ -304,7 +304,9 @@ copy_from_pui (puObject * object, SGPropertyNode * node)
         // Special case to handle lists, as getStringValue cannot be overridden
         if(object->getType() & PUCLASS_LIST)
         {
-            node->setStringValue(((puList *) object)->getListStringValue());
+            const char *s = ((puList *) object)->getListStringValue();
+            if (s)
+                node->setStringValue(s);
         }
         else
         {
index 5902a68ca1fafead66bdba89d5f7578dbb8de54a..b99ccd4051b66d2547938c0e180af2d0c464d838 100644 (file)
@@ -79,7 +79,8 @@ puList::newList (char ** contents)
 char *
 puList::getListStringValue ()
 {
-    return _contents[_list_box->getIntegerValue()];
+    int i = _list_box->getIntegerValue();
+    return i < 0 ? 0 : _contents[i];
 }
 
 int