Added code to Ondestroy() to do an AddRef() before calling DispatchStandardEvent()

and then a Release() afterwards. This ensures the object doesn't get destroyed until
after we've dispatched the event
This commit is contained in:
troy%netscape.com 1998-08-06 02:11:43 +00:00
Родитель 032ca1e974
Коммит c876b84e2e
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -1737,7 +1737,15 @@ void nsWindow::OnDestroy()
NS_RELEASE(mToolkit); NS_RELEASE(mToolkit);
mToolkit = NULL; mToolkit = NULL;
} }
if (!mIsDestroying) {
// Dispatching of the event may cause the reference count to drop to 0
// and result in this object being destroyed. To avoid that, add a reference
// and then release it after dispatching the event
AddRef();
DispatchStandardEvent(NS_DESTROY); DispatchStandardEvent(NS_DESTROY);
Release();
}
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------