mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 683063, part 1: Don't delete ContentParent out from under the cleanup process. r=jdm
This commit is contained in:
parent
20ce360676
commit
bf28d587e1
@ -269,6 +269,7 @@ ContentParent::OnChannelConnected(int32 pid)
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
||||
{
|
||||
@ -276,6 +277,20 @@ DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
||||
->PostTask(FROM_HERE,
|
||||
new DeleteTask<GeckoChildProcessHost>(aSubprocess));
|
||||
}
|
||||
|
||||
// This runnable only exists to delegate ownership of the
|
||||
// ContentParent to this runnable, until it's deleted by the event
|
||||
// system.
|
||||
struct DelayedDeleteContentParentTask : public nsRunnable
|
||||
{
|
||||
DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { }
|
||||
|
||||
// No-op
|
||||
NS_IMETHODIMP Run() { return NS_OK; }
|
||||
|
||||
nsRefPtr<ContentParent> mObj;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -366,6 +381,15 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
|
||||
PostTask(FROM_HERE,
|
||||
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
|
||||
mSubprocess = NULL;
|
||||
|
||||
// IPDL rules require actors to live on past ActorDestroy, but it
|
||||
// may be that the kungFuDeathGrip above is the last reference to
|
||||
// |this|. If so, when we go out of scope here, we're deleted and
|
||||
// all hell breaks loose.
|
||||
//
|
||||
// This runnable ensures that a reference to |this| lives on at
|
||||
// least until after the current task finishes running.
|
||||
NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
|
||||
}
|
||||
|
||||
TabParent*
|
||||
|
Loading…
Reference in New Issue
Block a user