Bug 337492 - Fix destructor race condition in proxy events, initial patch by Alex Fritze, with additional comments by me, r=me+dbaron

This commit is contained in:
benjamin%smedbergs.us 2007-05-25 11:18:18 +00:00
Родитель dcc5b28cea
Коммит f581c57307
2 изменённых файлов: 9 добавлений и 3 удалений

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

@ -57,9 +57,9 @@ nsProxyEventObject::nsProxyEventObject(nsProxyObject *aParent,
nsProxyEventClass* aClass,
already_AddRefed<nsISomeInterface> aRealInterface,
nsresult *rv)
: mRealInterface(aRealInterface),
mClass(aClass),
: mClass(aClass),
mProxyObject(aParent),
mRealInterface(aRealInterface),
mNext(nsnull)
{
*rv = InitStub(aClass->GetProxiedIID());
@ -71,6 +71,11 @@ nsProxyEventObject::~nsProxyEventObject()
// XXX assert this!
mProxyObject->LockedRemove(this);
// mRealInterface must be released before mProxyObject so that the last
// release of the proxied object is proxied to the correct thread.
// See bug 337492.
mRealInterface = nsnull;
}
//

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

@ -181,9 +181,10 @@ public:
private:
~nsProxyEventObject();
nsCOMPtr<nsISomeInterface> mRealInterface;
// Member ordering is important: See note in the destructor.
nsProxyEventClass *mClass;
nsCOMPtr<nsProxyObject> mProxyObject;
nsCOMPtr<nsISomeInterface> mRealInterface;
// Weak reference, maintained by the parent nsProxyObject
nsProxyEventObject *mNext;