From: mfranz Date: Tue, 23 May 2006 20:24:56 +0000 (+0000) Subject: treat widget input correctly X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9c9876670045520a911304e7c45a2f3bdc997bc6;p=flightgear.git treat widget input correctly --- diff --git a/src/GUI/property_list.cxx b/src/GUI/property_list.cxx index 76de60314..28dc91973 100644 --- a/src/GUI/property_list.cxx +++ b/src/GUI/property_list.cxx @@ -111,10 +111,9 @@ void PropertyList::delete_arrays() for (int i = 0; i < _num_entries; i++) delete[] _entries[i]; - for (int j = 0; j < _num_children; j++) { + for (int j = 0; j < _num_children; j++) if (!_children[j]->nChildren()) _children[j]->removeChangeListener(this); - } delete[] _entries; delete[] _children; @@ -297,9 +296,23 @@ void PropertyList::valueChanged(SGPropertyNode *nd) void PropertyList::setValue(const char *s) { - SGPropertyNode *p = fgGetNode(s, false); - if (p) - setCurrent(p); + SGPropertyNode *p; + try { + p = fgGetNode(s, false); + } catch (const stdString& m) { + SG_LOG(SG_GENERAL, SG_DEBUG, "property-list: " << m); + return; + } + setCurrent(p); } +void PropertyList::setCurrent(SGPropertyNode *p) +{ + bool same = (_curr == p); + _return = _curr = p; + update(same); + if (!same) + publish(p); +} + diff --git a/src/GUI/property_list.hxx b/src/GUI/property_list.hxx index 90965f02c..b044361b1 100644 --- a/src/GUI/property_list.hxx +++ b/src/GUI/property_list.hxx @@ -36,7 +36,7 @@ public: ~PropertyList(); void update (bool restore_slider_pos = false); - void setCurrent(SGPropertyNode *p) { _curr = p; update(); publish(p); } + void setCurrent(SGPropertyNode *p); SGPropertyNode *getCurrent() const { return _curr; } void publish(SGPropertyNode *p) { _return = p; invokeCallback(); } void toggleFlags() { _flags->setBoolValue(!_flags->getBoolValue()); }