[Flightgear-devel] SimGear bug? read-only properties tied to object methods not initialized

2011-02-10 Thread Torsten Dreyer
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=double3.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=n3.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 SGRawValueT 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


[Flightgear-devel] Simgear Bug

2010-07-29 Thread Chris Baines
Hello,

I am trying to build simgear on Debian, but when I run make check in
the simgear/math folder I get the following output included below. Is
there something I can tweak to fix this bug? 

Thanks,

Chris

make  SGMathTest SGGeometryTest
make[1]: Entering directory
`/home/chris/Packaging/Flightgear/SimgearDevPackage/Test
Build/SimGear-2.0.0/simgear/math'
g++ -DHAVE_CONFIG_H -I. -I../../simgear -I../..-g -O2 -D_REENTRANT
-MT SGMathTest.o -MD -MP -MF .deps/SGMathTest.Tpo -c -o SGMathTest.o
SGMathTest.cxx
SGMathTest.cxx: In function ‘bool sgInterfaceTest()’:
SGMathTest.cxx:259: error: ‘struct SGVec3f’ has no member named ‘sg’
SGMathTest.cxx:260: error: ‘struct SGVec3f’ has no member named ‘sg’
SGMathTest.cxx:268: error: ‘struct SGVec4f’ has no member named ‘sg’
SGMathTest.cxx:269: error: ‘struct SGVec4f’ has no member named ‘sg’
SGMathTest.cxx:277: error: ‘struct SGQuatf’ has no member named ‘sg’
SGMathTest.cxx:278: error: ‘struct SGQuatf’ has no member named ‘sg’
SGMathTest.cxx: In function ‘bool sgdInterfaceTest()’:
SGMathTest.cxx:308: error: ‘struct SGVec3d’ has no member named ‘sg’
SGMathTest.cxx:309: error: ‘struct SGVec3d’ has no member named ‘sg’
SGMathTest.cxx:317: error: ‘struct SGVec4d’ has no member named ‘sg’
SGMathTest.cxx:318: error: ‘struct SGVec4d’ has no member named ‘sg’
SGMathTest.cxx:326: error: ‘struct SGQuatd’ has no member named ‘sg’
SGMathTest.cxx:327: error: ‘struct SGQuatd’ has no member named ‘sg’
make[1]: *** [SGMathTest.o] Error 1
make[1]: Leaving directory
`/home/chris/Packaging/Flightgear/SimgearDevPackage/Test
Build/SimGear-2.0.0/simgear/math'
make: *** [check-am] Error 2




--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Simgear Bug

2010-07-29 Thread James Turner

On 29 Jul 2010, at 10:37, Chris Baines wrote:

 I am trying to build simgear on Debian, but when I run make check in
 the simgear/math folder I get the following output included below. Is
 there something I can tweak to fix this bug? 

'make check' works in latest Git source, though I wasn't aware anything had 
changed in this area since 2.0 - slightly odd. I'd suggest you take a look at 
the git logs for simgear/math since 2.0.0, and if you can't find an obvious 
smoking gun, let me know.

James



--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel