Bug 774388 - Patch 13: Temporarily addref to prevent destruction during handling of sync Stop message, to avoid triggering the 'mismatched CxxStackFrames' assertion of MessageChannel - r=nical

This commit is contained in:
Benoit Jacob 2014-07-04 14:04:12 -04:00
parent c741cc162f
commit 809ef59398

View File

@ -172,10 +172,25 @@ bool ImageBridgeParent::RecvWillStop()
return true;
}
static void
ReleaseImageBridgeParent(ImageBridgeParent* aImageBridgeParent)
{
aImageBridgeParent->Release();
}
bool ImageBridgeParent::RecvStop()
{
// Nothing to do. This message just serves as synchronization between the
// This message just serves as synchronization between the
// child and parent threads during shutdown.
// There is one thing that we need to do here: temporarily addref, so that
// the handling of this sync message can't race with the destruction of
// the ImageBridgeParent, which would trigger the dreaded "mismatched CxxStackFrames"
// assertion of MessageChannel.
AddRef();
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableFunction(&ReleaseImageBridgeParent, this));
return true;
}