Examiner Viewer destruction bug

Examiner Viewer destruction bug

Post by aland.. » Tue, 15 Jun 1999 04:00:00



In my application I need to be able to create and destroy Viewers at
will.  The problem I'm having is that when the number of existng
Viewers reaches zero for the second time, the scene is no longer
visible in subsequently created Viewers.  The following example can
illustrate the problem.  The first Viewer created in main() initializes
fine as does the second Viewer, created in the timeout procedure.  Just
before I create a subsequent Viewer, I destroy the previous one.  But
the second and subsequent times in the timeout procedure the scene is
no longer visible.  However, if I modify the timeout procedure slightly
by moving the Viewer destruction to occur just after I have created a
new Viewer, the behavior looks good.  I'm not sure what is happening
here.  Is this a bug?  If so how do I avoid the problem?

Thanks for any help you can provide.

#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/soSeparator.h>

SoXtExaminerViewer *myViewer;
SoSeparator *myRoot;
Widget myWindow;

void timeout(XtPointer,XtIntervalId *)
{
   delete myViewer;

   myViewer = new SoXtExaminerViewer(myWindow);
   myViewer->setSceneGraph(myRoot);
   myViewer->show();

   XtAppAddTimeOut(SoXt::getAppContext(),1000,timeout,myWindow);

Quote:}

void main(int argc,char **argv) {
   myWindow = SoXt::init(argv[0]);

   myRoot = new SoSeparator();
   myRoot->ref();

   SoCone *myCone = new SoCone();
   myRoot->addChild(myCone);

   myViewer = new SoXtExaminerViewer(myWindow);
   myViewer->setSceneGraph(myRoot);
   myViewer->show();

   SoXt::show(myWindow);

   XtAppAddTimeOut(SoXt::getAppContext(),1000,timeout,myWindow);

   SoXt::mainLoop();

Quote:}

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
 
 
 

Examiner Viewer destruction bug

Post by Jonathan Li » Tue, 15 Jun 1999 04:00:00



> In my application I need to be able to create and destroy Viewers at
> will.  The problem I'm having is that when the number of existng
> Viewers reaches zero for the second time, the scene is no longer
> visible in subsequently created Viewers.  The following example can
> illustrate the problem.  The first Viewer created in main() initializes
> fine as does the second Viewer, created in the timeout procedure.  Just
> before I create a subsequent Viewer, I destroy the previous one.  But
> the second and subsequent times in the timeout procedure the scene is
> no longer visible.  However, if I modify the timeout procedure slightly
> by moving the Viewer destruction to occur just after I have created a
> new Viewer, the behavior looks good.  I'm not sure what is happening
> here.  Is this a bug?  If so how do I avoid the problem?

> Thanks for any help you can provide.

> void timeout(XtPointer,XtIntervalId *)
> {
>    delete myViewer;

>    myViewer = new SoXtExaminerViewer(myWindow);
>    myViewer->setSceneGraph(myRoot);
>    myViewer->show();

>    XtAppAddTimeOut(SoXt::getAppContext(),1000,timeout,myWindow);
> }

> void main(int argc,char **argv) {
>    myWindow = SoXt::init(argv[0]);

>    myRoot = new SoSeparator();
>    myRoot->ref();

>    myViewer = new SoXtExaminerViewer(myWindow);
>    myViewer->setSceneGraph(myRoot);

My guess is that myRoot's reference count is down to zero. If I'm not
mistaken, the scene graph is unref'd each time the viewer is deleted.

              Jonathan Lim  _  Silicon Graphics  _  Mountain View
              GPS Graphics     Computer Systems        CA, USA

 
 
 

Examiner Viewer destruction bug

Post by Theodore W. Hal » Wed, 16 Jun 1999 04:00:00



> The problem I'm having is that when the number of existing Viewers
> reaches zero for the second time, the scene is no longer visible in
> subsequently created Viewers.

> My guess is that myRoot's reference count is down to zero. If I'm not
> mistaken, the scene graph is unref'd each time the viewer is deleted.

Hmm - that was my first thought, too.  But he explicitly ref()s `myRoot'
in main().  Unless he also unref()s it someplace, the refcount shouldn't
go below 1.  The viewer shouldn't unref() unless it previously ref()ed
it as well, so the refcount would go from 1 to 2 and back to 1, but not
0.

Anyway, it's not dumping core, as it would probably do if `myRoot' had
been deleted.


doesn't say whether the scene graph includes a camera, or whether he
repositions the camera between views.  But, the default viewer is a
BROWSER, not an EDITOR, so whatever happens to the camera in one viewer
shouldn't affect the way the next viewer sees it.  ???

--

Ted Hall                        |
Department of Architecture      |

Sha Tin, HONG KONG              | http://www.arch.cuhk.edu.hk/~hall/

 
 
 

Examiner Viewer destruction bug

Post by aland.. » Wed, 16 Jun 1999 04:00:00





> doesn't say whether the scene graph includes a camera, or whether he
> repositions the camera between views.  But, the default viewer is a
> BROWSER, not an EDITOR, so whatever happens to the camera in one
viewer
> shouldn't affect the way the next viewer sees it.  ???

Thanks for looking into my problem.  Let me answer some of the specific
questions that were raised in the responses.  The reference counting of
'myRoot' does not go to 0 as you pointed out.  I printed the reference
count value and it does in fact toggle between 1 and 2 and the program
never crashes as one would expect if the root node did ever reach 0.
Also, this scene graph only has the root node and a cone.  The camera
and light are provided automatically by the viewer.  I am not
manipulating the viewer's camera or light or any other viewer attribute
in anyway.

I would appreciate any further assistance.

Thanks
Alan Dunn

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

1. Examiner viewer problem

Hello,
        I have a problem with the orthographic camera in the examiner viewer.
If I put a dragger in my scene and pick on it with the perspective view
the dragger work fine. But if I change the type of view in examiner viewer to
a orthographic camera I can't pick the dragger. The same thing appen when I
make long zoom out and I use the orthographic view.

Something can say me why?

The Open Inventor version is: 2.0

                                Thanks. Massimo.

--
~~                                                       -    -    --    -    -
Pighetti Massimo                                        --  --   -  -    -  -
Laboratorio Eidomatica                                 - -- -  -    -    --
Universita' Statale di Milano                         -    -  ------    --
Dip. di Scienze dell' Informazione                   -    -  -    -   -  -
Via Comelico 39 20135 Milano ITALIA                 -    -  -    -  -    -
URL: http://escher.usr.dsi.unimi.it/home/pighetti/index.html

2. How to generate contrasting colors?

3. Inventor Examiner Viewer

4. Raytracer for 3DS3

5. ViewKit/Inventor Examiner Viewer

6. Data Shaper

7. Inventor Manips and Examiner Viewer

8. OpenInventor: Cameras and Examiner Viewer

9. Examiner viewer

10. TGS Examiner Viewer in ActiveX Control

11. 2 examiner viewers

12. Rotating in examiner viewer