add deathgrip to JSContext to prevent its untimely destruction. fixes bug 20193. r:brendan@mozilla.org

This commit is contained in:
danm%netscape.com 1999-12-07 02:39:17 +00:00
Родитель 2f6776efa2
Коммит 1b74898ee7
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -531,6 +531,12 @@ nsJSContext::CallFunctionObject(void *aObj, void *aFunObj, PRUint32 argc,
if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext)))
return NS_ERROR_FAILURE;
// this context can be deleted unexpectedly if the JS closes
// the owning window. we ran into this problem specifically
// when going through the "close window" key event handler
// (that is, hitting ^W on Windows). the addref just below
// prevents our untimely destruction.
nsCOMPtr<nsJSContext> kungFuDeathGrip(this);
mRef = nsnull;
mTerminationFunc = nsnull;