[osg-users] ViewerQT destruction

Kallfass, Daniel Daniel.Kallfass at eads.com
Thu Jul 3 03:44:59 PDT 2008

Hi Robert,

Concerning your build error:
try using Qt::WA_DeleteOnClose instead of Qt::WDestructiveClose because
WDestructiveClose is an obsolete flag.


-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Robert
Sent: Thursday, July 03, 2008 12:08 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ViewerQT destruction

Hi Virgina,

I have compiled you on my system, compiling against QT4, and get the

error: 'WDestructiveClose' is not a member of 'Qt'
make[2]: ***
Error 1
make[1]: ***
Error 2
make: *** [all] Error 2

I'm not very familiar with Qt so don't know the best way to map this
across to QT4.  Suggesstions?

As a general note, when you have multiple views of a single scene
graph, the right tool to use is osgViewer::ComposteiViewer rather than
Viewer as otherwise you end up with duplicated update traversals and
out of sync frame stamps.  Having things work event driven does
complicate things though, as CompositeViewer is designed around a
having single frame call that updates all windows at one time.
Supporting the event driven model with CompositeViewer/Viewer better
will something that we'll need to work on - this doesn't change the
crash issue, but it's something to bare in mind for the future.


On Wed, Jul 2, 2008 at 6:59 PM, Virginia Holmstrom
<v.holmstrom at ama-inc.com> wrote:
> Robert-
> I have modified AdapterWidget.cpp from the osgviewerQt example. Use
with Osg 2.4, Qt 3.3.3. It is obviously much simplified from what I have
but exhibits a similar problem.
> What I changed:
> 1. Created 3 ViewerQts instead of just 1
> 2. Added a destructor to ViewerQt
> 3. Added the Qt::WDestructiveClose flag to the AdapterWidget, which
triggers the ViewerQt destructor to be called when the window is closed
> How to use:
> 1. osgViewerQTd.exe cow.osg
> 2. Mine pops up cascaded, cow in each window
> 3. Close a window (middle window works well for me)
> 4. Check remaining windows, cow will likely have disappeard from one
of them
> 5. If this didn't work, try closing the other windows, or running
again and closing the windows in a different order.
> Thank you so much,
> Virginia
> Hi Virginia,
> There is not much I can do without seeing the problem first hand.  Is
it possible to recreate it by modifying the existing osgviewerQT
example?  If so, could do this to effectively create a unit test for
this particular usage case.
> Another possible route with solving this type of usage case might be
to explicitly pass in the parent window when creating the graphics
context, but leave it to the OSG itself to create the windows rather
that QT.  I haven't personally tried this, but it should be possible,
even if it requires a few tweaks to the OSG itself to enable it.
> Robert.
> On Wed, Jul 2, 2008 at 3:22 PM, Virginia Holmstrom
<v.holmstrom at ama-inc.com> wrote:
>> Hello
>> 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
007-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
>> 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:
>> ViewerQT
>> osgViewer::Viewer
>> osgViewer::View
>> osg::View
>> AdapterWidget
>> We normally perform cleanup of our own classes in
>> however we see the corruption when the ViewerQT destructor is empty
>> 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
>> If I subsequently open a new window the scene usually appears normal.
>> I am not sure if I have a:
>> memory problem?
>> problem with the shared scene when ViewerQTs destruct?
>> problem in the GraphicsWindowEmbedded?
>> QT problem?
>> ???
>> I am very open to suggestions. ;-)
>> Thank you so much,
>> Virginia
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> org
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list