[osg-users] ViewerQT destruction
v.holmstrom at ama-inc.com
Wed Jul 2 07:22:23 PDT 2008
I have been having problems with the destruction of my ViewerQT window and I was wondering if anyone could shed some light on the issue. I am seeing corruption in one view when another view is deleted (screen shot attached). We are using OSG 2.4 and Qt 3.3.3 on WindowsXP and Linux. Problems are reproducible on both platforms.
We are required to permit muliple views into the same scene, each in its own window with its own navigation. The user may open one or more views, close views at anytime, and open new ones. We have a set up similar to the osgViewerQT example shipped with osg, where our ViewerQT inherits from both osgViewer::Viewer and the AdapterWidget. We actually flipped the inheritance order from the example, so that ours looks like this: ViewerQT : public AdapterWidget, public osgViewer::Viewer
due to compilation problems with the Qt moc'ing the other way around.
Note we are using QGLWidget, not QOSGWidget, and we use multiple ViewerQts instead of CompositeViewer due to problems discussed in thread http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2007-December/005676.html. Hence our use of multiple ViewerQts is also similar to Enrique Parodi's implementation he provided in that thread.
We store a ref_ptr to the root node of our scene external to the ViewerQts.
osg::ref_ptr < osg::Group > _osgScene;
This ref_ptr persists as views are opened and closed and is only released when the application closes. Each time a ViewerQT is created we pass it the scene using setSceneData. All ViewerQts get the same root scene node.
We started having a problem when we set the Qt::WDestructiveClose flag in our AdapterWidget, which triggers the following destructors to be called in this order on close:
We normally perform cleanup of our own classes in ViewerQT::~ViewerQT, however we see the corruption when the ViewerQT destructor is empty as well! The AdapterWidget destructor contains _gw->getEventQueue()->closeWindow();
The easiest way to reproduce the problem is to open multiple windows, then close the first window(view), triggering its destruction. Frequently the last window will be corrupted. I use corruption for lack of a better term. Geometry may disappear, textures may disappear, osgText may become blocks, while other parts of the scene are still visible in their original form. We've also had problems with the background stars flipping to an opaque dome.
In the screen shot provided I closed the first window (hence blank space upper left) and immediatly as I did that portions of the scene disappeard from the last window (bottom right) and the text became blocks.
If I subsequently open a new window the scene usually appears normal.
I am not sure if I have a:
problem with the shared scene when ViewerQTs destruct?
problem in the GraphicsWindowEmbedded?
I am very open to suggestions. ;-)
Thank you so much,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 102163 bytes
Desc: not available
More information about the osg-users