Bug 474406. Revoke our pending constructor processing event if our document goes away. r+sr=sicking

This commit is contained in:
Boris Zbarsky 2009-02-03 21:58:21 -05:00
Родитель 60d169556d
Коммит e81305d982
2 изменённых файлов: 6 добавлений и 4 удалений

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

@ -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<nsBindingManager>(
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;
}

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

@ -306,7 +306,7 @@ protected:
// Our posted event to process the attached queue, if any
friend class nsRunnableMethod<nsBindingManager>;
nsCOMPtr<nsIRunnable> mProcessAttachedQueueEvent;
nsRefPtr< nsRunnableMethod<nsBindingManager> > mProcessAttachedQueueEvent;
// Our document. This is a weak ref; the document owns us
nsIDocument* mDocument;