Hi all - here comes a tricky one: (good bugs are usually tricky - not everything tricky is necessarily a bug)
Imagine an arbitrary PropertyList config file like this: <PropertyList> <foo type="double">3.14</foo> </PropertyList> and a code fragment like class MyClass { public: double getter() const { return foo; } void setter( double d ) { foo = d; } void dosomethingfancy(); private: double foo; }; void MyClass::dosomethingfancy() { someBaseNode->tie( "foo", this, MyClass:getter, MyClass::setter ); } Ignore the fact, that it doesn't make much sense here - it's just an example. One would expect that foo in MyClass (and the value of the thereafter tied property) gets initialized to the value of <foo> from the config file which is 3.14. This actually works fine. Now, modify the xml file to look like this: <PropertyList> <foo type="double" write="n">3.14</foo> </PropertyList> (note: foo is now read-only) The value of the foo-property now remains at an unchangeable value of zero, it no longer gets initialized to the provided value in <foo>. That is because the property is declared read-only and the setter method never gets called. In simgear/props/props.hxx in SGPropertyNode::tie() some code exist to set the value of a property after being tied, to the default value using setValue(). However, setValue() is smart enough to check for a read-only property and refuses to change a property value in that case. A fix might be to temporarily set the WRITE-flag for the property in the tie() method like this: (fragment from props.hxx, SGPropertyNode::tie(const SGRawValue<T> &rawValue, bool useDefault), line 1789ff if (useDefault) { int save_attributes = getAttributes(); // save current write-flag setAttribute( WRITE, true ); // write-enable the property setValue(old_val); // set the old value setAttributes( save_attributes ); // restore write-flag } instead of if (useDefault) { setValue(old_val); // noop for read-only property } Comments? Torsten ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel