So now I was able to replicate it again with a slightly different case. I tracked it down to a problem with the ChangeContainers but I am still not completely sure why it was happening.

The "fix" is here: http://opensg.vrsource.org/trac/changeset/600

The application I used to test it is attached (a modified 10loading.cpp that reloads the model each frame as part of the display update and deletes the old model). If you want the sample file we used to replicate the problem, just let me know and I can send it.

-Allen


Allen Bierbaum wrote:
Gerrit Voss wrote:
Hi,

On Sat, 2007-03-10 at 11:53 -0600, Allen Bierbaum wrote:
I have been tracking down some bugs in an application so I am sprinkling commitChanges() calls throughout my code. I know that sounds a bit imprecise, but we have found it to be the best way to find some bugs in OpenSG2 right now.

Anyway... I just ran into a bug. When I run the following code it segfaults in the first few (2-5) iterations through the loop.
I'm at 500 iterations right now and it is still running (Linux FC6, tie.wrl).

Could you give a few more hints what exactly your test looks like.

I can't replicate it either right now.  Maybe it was phantom code. :)

I will keep trying and see if I can get some failing code to send you.

Thanks,
Allen

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users


// OpenSG Tutorial Example: Loading
//
// This example shows how to load a scene file using OpenSG.
// The supported formats right now are VRML97, OBJ, OFF and RAW, so just
// calling this program with a scene file as a parameter should load the scene
// file.
//

// Headers
#include <OpenSG/OSGGLUT.h>
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
#include <OpenSG/OSGGLUTWindow.h>
#include <OpenSG/OSGSimpleSceneManager.h>
#include <OpenSG/OSGAction.h>

// New Headers

// the general scene file loading handler
#include <OpenSG/OSGSceneFileHandler.h>
#include <boost/bind.hpp>

// Activate the OpenSG namespace
OSG_USING_NAMESPACE

// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
std::string   gFileName;
GroupNodePtr  gScene;

// forward declaration so we can have the interesting stuff upfront
int setupGLUT( int *argc, char *argv[] );


// helper class to find a named node
// names are handled as simple attachments, get the header for that
#include <OpenSG/OSGSimpleAttachments.h>

// There are two convenience functions for name access: getName() and
// setName(). For details about general attachment handling see the
// attachments tutorial

class NamedNodeFinder
{
  public:

    NamedNodeFinder(void) : _name(), _found() {}

    NodePtr operator() (NodePtr root, std::string name)
    {
        _name=&name;
        _found=NullFC;

        TraverseEnterFunctor enter =
            boost::bind(&NamedNodeFinder::check, this, _1);
        traverse(root, enter);

        return _found;
    }

    static NodePtr find(NodePtr root, std::string name)
    {
        NamedNodeFinder f;

        return f(root,name);
    }

  private:

    Action::ResultE check(NodePtr node)
    {
        if(getName(node) && *_name == getName(node))
        {
            _found = node;
            return Action::Quit;
        }

        return Action::Continue;
    }

    NodePtr  _found;
    std::string  *_name;
};

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG
    GLUTWindowPtr gwin= GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();

    // load the scene
    gScene = GroupNodePtr::create();


    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));

        std::list<const char*> suffixes;
        SceneFileHandler::the()->getSuffixList(suffixes);
        //SceneFileHandler::the()->print();

        for(std::list<const char*>::iterator it  = suffixes.begin();
                                             it != suffixes.end();
                                           ++it)
        {
            FWARNING(("%s\n", *it));
        }

        //scene = makeTorus(.5, 2, 16, 16);
        NodeRefPtr model = NodeRefPtr(makeSphere(6,4));
        SceneFileHandler::the()->write(model, "/var/tmp/sphere.osb");
        gScene.node()->addChild(model);
    }
    else
    {
        /*
            All scene file loading is handled via the SceneFileHandler.
        */
        NodeRefPtr model = NodeRefPtr(SceneFileHandler::the()->read(argv[1]));
        gFileName = std::string(argv[1]);
        gScene.node()->addChild(model);
    }


    NodePtr found;

    NamedNodeFinder f;


    commitChanges();

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (gScene.node());

    // show the whole scene
    mgr->showAll();

    // GLUT main loop
    glutMainLoop();

    return 0;
}

//
// GLUT callback functions
//

// redraw the window
void display(void)
{
   static int i=0;
   i++;
    // Load the geom again under the scene and delete the other one
    std::cerr << i << ": ============================================" << std::endl;
    std::cerr << " ----- sub child: -----------" << std::endl;
    NodeRefPtr old_child( gScene.node()->getChild(0) );
    gScene.node()->subChild(0);

    //Thread::getCurrentChangeList()->dump();
    std::cerr << "--------> Commit" << std::endl;

    commitChanges();

    std::cerr << " -------- load/add child: -----------" << std::endl;
    NodeRefPtr model = NodeRefPtr(SceneFileHandler::the()->read(gFileName.c_str()));
    gScene.node()->addChild(model);

    //Thread::getCurrentChangeList()->dump();
    std::cerr << "--------> Commit" << std::endl;
    commitChanges();

    mgr->idle();
    mgr->redraw();
}

// react to size changes
void reshape(int w, int h)
{
    mgr->resize(w, h);
    glutPostRedisplay();
}

// react to mouse button presses
void mouse(int button, int state, int x, int y)
{

    if (state)
        mgr->mouseButtonRelease(button, x, y);
    else
        mgr->mouseButtonPress(button, x, y);

    glutPostRedisplay();
}

// react to mouse motions with pressed buttons
void motion(int x, int y)
{

    mgr->mouseMove(x, y);
    glutPostRedisplay();
}

// react to keys
void keyboard(unsigned char k, int , int )
{
    switch(k)
    {
        case 27:
        {
            OSG::osgExit();
            exit(0);
        }
        break;

        case 'f':
        {
            mgr->setNavigationMode(Navigator::FLY);
        }
        break;

        case 't':
        {
            mgr->setNavigationMode(Navigator::TRACKBALL);
        }
        break;
    }
}

// setup the GLUT library which handles the windows for us
int setupGLUT(int *argc, char *argv[])
{
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("OpenSG");

    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    return winid;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to