Code

Fix [ 1835591 ] Reproducible crash on opening the attached file
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 23 Nov 2007 19:40:07 +0000 (19:40 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 23 Nov 2007 19:40:07 +0000 (19:40 +0000)
src/ui/widget/registered-enums.h
src/ui/widget/registered-widget.cpp

index 6dfa48b7af18adf1485ca29e0796a07319b9cf93..0a17aeca369936230a335e657dc5a50bb33afef8 100644 (file)
@@ -55,15 +55,23 @@ public:
     }
 
     void set_active_by_id (E id) {
-        combobox()->set_active_by_id(id);
+        ComboBoxEnum<E> * cb = combobox();
+        if (cb)
+            cb->set_active_by_id(id);
     };
 
     void set_active_by_key (const Glib::ustring& key) {
-        combobox()->set_active_by_key(key);
+        ComboBoxEnum<E> * cb = combobox();
+        if (cb)
+        cb->set_active_by_key(key);
     }
 
     inline const Util::EnumData<E>* get_active_data() {
-        return combobox()->get_active_data();
+        ComboBoxEnum<E> * cb = combobox();
+        if (cb)
+            return cb->get_active_data();
+        else
+            return NULL;
     }
 
     ComboBoxEnum<E> * combobox() {
index 804a403f6dab0d73db055963b6137a05aba0379f..1ee52cc99cfc2e430c551eb3dc891748d3f63fcc 100644 (file)
@@ -221,16 +221,19 @@ RegisteredScalarUnit::getSU()
 void
 RegisteredScalarUnit::setValue (double val)
 {
-    _widget->setValue (val);
+    if (_widget)
+        _widget->setValue (val);
 }
 
 void
 RegisteredScalarUnit::on_value_changed()
 {
+g_message("on_value_changed");
     if (_widget->setProgrammatically) {
         _widget->setProgrammatically = false;
         return;
     }
+g_message("on_value_changed1");
 
     if (_wr->isUpdating())
         return;
@@ -284,7 +287,8 @@ RegisteredScalar::getS()
 void
 RegisteredScalar::setValue (double val)
 {
-    _widget->setValue (val);
+    if (_widget)
+        _widget->setValue (val);
 }
 
 void
@@ -483,9 +487,15 @@ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument
 void
 RegisteredRadioButtonPair::setValue (bool second)
 {
+    if (!_rb1 || !_rb2)
+        return;
+
     setProgrammatically = true;
-    if (second) _rb2->set_active();
-    else        _rb1->set_active();
+    if (second) {
+        _rb2->set_active();
+    } else {
+        _rb1->set_active();
+    }
 }
 
 void
@@ -549,7 +559,8 @@ RegisteredPoint::getPoint()
 void
 RegisteredPoint::setValue (double xval, double yval)
 {
-    _widget->setValue(xval, yval);
+    if (_widget)
+        _widget->setValue(xval, yval);
 }
 
 void
@@ -615,6 +626,9 @@ RegisteredRandom::getR()
 void
 RegisteredRandom::setValue (double val, long startseed)
 {
+    if (!_widget)
+        return;
+
     _widget->setValue (val);
     _widget->setStartSeed(startseed);
 }