Commit fb1b3ec9 authored by whitlocb's avatar whitlocb
Browse files

I fixed a crash I ran into where passing as class as user-data to a callback...

I fixed a crash I ran into where passing as class as user-data to a callback would cause the CLI to core on exit.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12271 18c085ea-50e0-402c-830e-de6fd14e8384
parent f4b36828
......@@ -149,6 +149,9 @@ CallbackManager::CallbackManager(ViewerProxy *p) : SimpleObserver(),
// Brad Whitlock, Wed Feb 6 10:28:58 PST 2008
// Added support for callback data.
//
// Brad Whitlock, Thu Aug 19 15:52:59 PDT 2010
// Be careful about deleting a class instance from here.
//
// ****************************************************************************
CallbackManager::~CallbackManager()
......@@ -161,7 +164,18 @@ CallbackManager::~CallbackManager()
if(it->second.pycb != 0)
Py_DECREF(it->second.pycb);
if(it->second.pycb_data != 0)
Py_DECREF(it->second.pycb_data);
{
// Hack! I found that decrementing the refcount of a class
// instance from here causes a crash if it's the last
// reference and it will cause the object to be deleted.
// Decrementing the refcount on other object types is fine,
// even if it causes the object to get deleted. Other objects
// work okay so our reference counting seems good.
bool lastInstance = Py_REFCNT(it->second.pycb_data) == 1 &&
PyInstance_Check(it->second.pycb_data);
if(!lastInstance)
Py_DECREF(it->second.pycb_data);
}
}
delete threading;
}
......
......@@ -69,6 +69,8 @@ ViewerRPCCallbacks::ViewerRPCCallbacks()
// Creation: Tue Feb 5 11:46:12 PST 2008
//
// Modifications:
// Brad Whitlock, Thu Aug 19 15:52:59 PDT 2010
// Be careful about deleting a class instance from here.
//
// ****************************************************************************
......@@ -79,7 +81,18 @@ ViewerRPCCallbacks::~ViewerRPCCallbacks()
if(pycb[r] != 0)
Py_DECREF(pycb[r]);
if(pycb_data[r] != 0)
Py_DECREF(pycb_data[r]);
{
// Hack! I found that decrementing the refcount of a class
// instance from here causes a crash if it's the last
// reference and it will cause the object to be deleted.
// Decrementing the refcount on other object types is fine,
// even if it causes the object to get deleted. Other objects
// work okay so our reference counting seems good.
bool lastInstance = Py_REFCNT(pycb_data[r]) == 1 &&
PyInstance_Check(pycb_data[r]);
if(!lastInstance)
Py_DECREF(pycb_data[r]);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment