Martin Karlsson wrote:
> Hi Carsten!
> 
> The modified tutorial file i made is at the bottom of this mail.
> I'm using the cvs version from sourceforge of OpenSG.

ok, thanks. First I want to apologize for the delay in answering, I had
to build a clean tree first and then had trouble understanding the
problem in the modified tutorial.

The problem is that you do not pull the changes done during scene setup
into the foo thread, i.e. in the foo thread (aspect 1) the Node scene
does not have a core (the torus in aspect 0), because that is only set
when performing the sync. Now foo adds a child, but does not use field
mask in the beginEditCP/endEditCP calls, thus all fields of the Node
scene are considered as modified. When syncing the main thread with the
foo thread the empty core is copied to the main thread, resulting in the
error message you see.
[I know the online tutorial example does not handle this either, it gets
away with it because it does not do any structural changes to the scene
- I'll fix this next.]


If you change the beginning of the foo thread function like:

void foo(void *ptr)
{
    std::cerr << "Pulling in changes from app thread.." << std::endl;

    syncBarrier->enter(2);
    Thread *appThread =
dynamic_cast<Thread*>(ThreadManager::getAppThread());

    if(appThread == 0)
        return;

    appThread->getChangeList()->apply();
    syncBarrier->enter(2);

    std::cerr << "Synced foo thread to app thread." << std::endl;

        // rest of function ...
}

and main before the call to glutMainLoop like this:

    syncBarrier->enter(2);
    syncBarrier->enter(2);

    // GLUT main loop
    glutMainLoop();
    return 0;
}

Then the program should behave as expected - well, at least it does for
me ;)

 > About the other problem with barrier syncing between threads/objects; i
> managed to half-way solve it. It doesn't crash anymore :)
> I modified the callSync method to the following:
> 
> void OpenSGClient::callSync(){
>          std::cout << "callSync called\n";
>       syncBarrier::get(NULL);                 // added this line
>          needSync = true;
>          syncBarrier->enter(2);
>          syncBarrier->enter(2);
> }
> 
> I'm not sure why i have to reinitialize the syncbarrier, it's allready 
> been initialized in the constructor.

I'm pretty sure this only papers over the real problem. I suspect that
code contains the same problem as the tutorial code you sent. Please try
fixing that, if the issue remains we'll try to find its cause.

        Cheers,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to