Carsten Neumann wrote:
> the reference count is stored in the pointed-to object ...
...
> some ideas to debug this further:
> - you can access the reference count of an object with
> FieldContainer::getRefCount()
I've been having a similar issue with a MultiDisplayWindowRefPtr, so I
followed your advice:
In my "open server" function:
// local variable
OSG::MultiDisplayWindow * multi_display_window
= static_cast<OSG::MultiDisplayWindow *> (
m_ClusterServer->getClusterWindow());
if (multi_display_window) std::cerr
<< "multi_display_window->getRefCount() = "
<< multi_display_window->getRefCount() << std::endl;
That prints "2" already. A little surprising, but OK.
// copy to class data variable
m_MultiDisplayWindow = multi_display_window;
if (m_MultiDisplayWindow) std::cerr
<< "m_MultiDisplayWindow->getRefCount() = "
<< m_MultiDisplayWindow->getRefCount() << std::endl;
That prints "3". OK.
In my "close" function:
// test class data variable
if (m_MultiDisplayWindow) std::cerr
<< "m_MultiDisplayWindow->getRefCount() = "
<< m_MultiDisplayWindow->getRefCount() << std::endl;
That still prints "3". OK.
// delete the ClusterServer
if (m_ClusterServer)
{
m_ClusterServer->stop ();
delete m_ClusterServer;
m_ClusterServer = NULL;
}
// test class data variable
if (m_MultiDisplayWindow) std::cerr
<< "m_MultiDisplayWindow->getRefCount() = "
<< m_MultiDisplayWindow->getRefCount() << std::endl;
That already prints "0", even though I have not yet destroyed or reset
m_MultiDisplayWindow. I expected it to be "1".
m_MultiDisplayWindow = NULL;
The program crashes here -- I guess because the MultiDisplayWindow was
already destroyed when its reference count went to zero, and now it's
trying to destroy it again.
* * *
My problem seems to be related to m_ClusterServer->stop (); I notice
that the demo program does not call that before deleting the server.
If I remove that call, my program exits cleanly.
--
Ted
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users