1.1 --- a/core/systems/HandleSys.cpp Sun May 13 21:45:40 2007 +0000
1.2 +++ b/core/systems/HandleSys.cpp Sun May 13 22:36:22 2007 +0000
1.3 @@ -285,6 +285,7 @@
1.4 pHandle->owner = owner;
1.5 pHandle->ch_next = 0;
1.6 pHandle->access_special = false;
1.7 + pHandle->is_destroying = false;
1.8
1.9 /* Create the hash value */
1.10 Handle_t hash = pHandle->serial;
1.11 @@ -601,6 +602,7 @@
1.12 {
1.13 /* Type should be the same but do this anyway... */
1.14 pType = &m_Types[pMaster->type];
1.15 + pMaster->is_destroying = true;
1.16 pType->dispatch->OnHandleDestroy(pMaster->type, pMaster->object);
1.17 ReleasePrimHandle(master);
1.18 }
1.19 @@ -613,6 +615,7 @@
1.20 /* Decrement, free if necessary */
1.21 if (--pHandle->refcount == 0)
1.22 {
1.23 + pHandle->is_destroying = true;
1.24 pType->dispatch->OnHandleDestroy(pHandle->type, pHandle->object);
1.25 ReleasePrimHandle(index);
1.26 } else {
1.27 @@ -646,6 +649,14 @@
1.28 return HandleError_Access;
1.29 }
1.30
1.31 + if (pHandle->is_destroying)
1.32 + {
1.33 + /* Someone tried to free this recursively.
1.34 + * We'll just ignore this safely.
1.35 + */
1.36 + return HandleError_None;
1.37 + }
1.38 +
1.39 return FreeHandle(pHandle, index);
1.40 }
1.41