Re: [osg-users] Problems with osg:: sharedObjects
Ah ... It's so obvious! Decades of programming is no guarantee for error free code. Thanks!!! On Wed, 26 Jan 2011 13:39:55 -0500, Jean-Sébastien Guay wrote: Hello Werner, D.J., I would recommend that you either: 1) use ref_ptr as your return type, or 2) wait to use ref_ptr outside of createObject. Or return obj1.release() instead of obj1.get(). This tells the ref_ptr to decrease its ref count, but not delete the object if it gets to 0 (contrary to get()). Which is what will happen in your case (check with a debugger). Incidentally, using a debugger would also have told you why it crashes... checking the pointer after the call to your function would have shown you that it had been deleted. J-S ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problems with osg:: sharedObjects
Dear community, Maybe someone of you can give me a hint. I'm running Windows 7 64 Bit and osg 2.8.3. I have a Qt application working with AdapterWidget. Al my scene works fine and is displayed the right way. After deleting my view (derived from AdapterWidget) and reinstantiation of the view again I have problems with sharedObjects. The same scene doesn't work any more. The following trivial sequence of code crashes the program: someSharedObject * createObject { osg::ref_ptrsomeSharedObject obj1 = new someSharedObject; return obj1.get(); } osg::ref_ptrsomeSharedObject obj2; obj2 = createObject(); // crashing here After restarting the program in the console the message appears: Fault tolerant heap shim applied to current process. This is usually due to previous crashes. The only reason I can imagine is the existance of static variables beeing uninitialized in the second run. Is there any hint where to look for that? I'd like to avoid reading tons of code. Another question in the context of testing: I found the tool spyGlass for tracking GL-calls. Is there any way to build it without visual studio? Like configure;make;make install ? Or ist there any other recommended tool? Thanks for any hints. - Werner - ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problems with osg:: sharedObjects
Hello, Werner. If I read your createObject correctly, you appear to be returning a raw pointer to an object that gets deleted within the function. Using ref_ptr in the local scope, but returning a raw pointer, results in the deletion of the object when you leave the function, since the only live reference is going out of scope. I would recommend that you either: 1) use ref_ptr as your return type, or 2) wait to use ref_ptr outside of createObject. Unfortunately, I can't offer any advice on your testing question, since I use always Visual Studio to build and use OSG. I hope this helps... D.J. On Wed, Jan 26, 2011 at 12:31 PM, Werner Modenbach wer...@texion.eu wrote: Dear community, Maybe someone of you can give me a hint. I'm running Windows 7 64 Bit and osg 2.8.3. I have a Qt application working with AdapterWidget. Al my scene works fine and is displayed the right way. After deleting my view (derived from AdapterWidget) and reinstantiation of the view again I have problems with sharedObjects. The same scene doesn't work any more. The following trivial sequence of code crashes the program: someSharedObject * createObject { osg::ref_ptrsomeSharedObject obj1 = new someSharedObject; return obj1.get(); } osg::ref_ptrsomeSharedObject obj2; obj2 = createObject(); // crashing here After restarting the program in the console the message appears: Fault tolerant heap shim applied to current process. This is usually due to previous crashes. The only reason I can imagine is the existance of static variables beeing uninitialized in the second run. Is there any hint where to look for that? I'd like to avoid reading tons of code. Another question in the context of testing: I found the tool spyGlass for tracking GL-calls. Is there any way to build it without visual studio? Like configure;make;make install ? Or ist there any other recommended tool? Thanks for any hints. - Werner - ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problems with osg:: sharedObjects
Hello Werner, D.J., I would recommend that you either: 1) use ref_ptr as your return type, or 2) wait to use ref_ptr outside of createObject. Or return obj1.release() instead of obj1.get(). This tells the ref_ptr to decrease its ref count, but not delete the object if it gets to 0 (contrary to get()). Which is what will happen in your case (check with a debugger). Incidentally, using a debugger would also have told you why it crashes... checking the pointer after the call to your function would have shown you that it had been deleted. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org