From e81305d9826fc6940c2bb01d661fbd0946138b7c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 3 Feb 2009 21:58:21 -0500 Subject: [PATCH] Bug 474406. Revoke our pending constructor processing event if our document goes away. r+sr=sicking --- content/xbl/src/nsBindingManager.cpp | 8 +++++--- content/xbl/src/nsBindingManager.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index 77d9c4b4f771..ec64b86f30d1 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -425,7 +425,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBindingManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_MEMBER(mAttachedStack, nsXBLBinding) // No need to traverse mProcessAttachedQueueEvent, since it'll just - // fire at some point. + // fire at some point or become revoke and drop its ref to us. NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_CLASS(nsBindingManager) @@ -965,8 +965,7 @@ void nsBindingManager::PostProcessAttachedQueueEvent() { mProcessAttachedQueueEvent = - new nsRunnableMethod( - this, &nsBindingManager::DoProcessAttachedQueue); + NS_NEW_RUNNABLE_METHOD(nsBindingManager, this, DoProcessAttachedQueue); nsresult rv = NS_DispatchToCurrentThread(mProcessAttachedQueueEvent); if (NS_SUCCEEDED(rv) && mDocument) { mDocument->BlockOnload(); @@ -1555,6 +1554,9 @@ nsBindingManager::DropDocumentReference() { // Make sure to not run any more XBL constructors mProcessingAttachedStack = PR_TRUE; + if (mProcessAttachedQueueEvent) { + mProcessAttachedQueueEvent->Revoke(); + } mDocument = nsnull; } diff --git a/content/xbl/src/nsBindingManager.h b/content/xbl/src/nsBindingManager.h index 75f4c888e61c..ca34af3a112a 100644 --- a/content/xbl/src/nsBindingManager.h +++ b/content/xbl/src/nsBindingManager.h @@ -306,7 +306,7 @@ protected: // Our posted event to process the attached queue, if any friend class nsRunnableMethod; - nsCOMPtr mProcessAttachedQueueEvent; + nsRefPtr< nsRunnableMethod > mProcessAttachedQueueEvent; // Our document. This is a weak ref; the document owns us nsIDocument* mDocument;