From 2b63405c0cbebab70f4dfc0b0030cf9d6d2b159d Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Fri, 17 Dec 2004 19:47:06 +0000 Subject: [PATCH] fixes bug 273819 "ASSERTION: Native event queues should only be used on the main thread" r=danm, sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@166818 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/nsEventQueue.cpp | 17 ++++++++++++++++- mozilla/xpcom/threads/nsEventQueue.h | 12 +----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mozilla/xpcom/threads/nsEventQueue.cpp b/mozilla/xpcom/threads/nsEventQueue.cpp index 04a945f2495..f7608beb048 100644 --- a/mozilla/xpcom/threads/nsEventQueue.cpp +++ b/mozilla/xpcom/threads/nsEventQueue.cpp @@ -135,7 +135,9 @@ nsEventQueueImpl::~nsEventQueueImpl() #endif if (mEventQueue) { - NotifyObservers(gDestroyedNotification); + // Perhaps CheckForDeactivation wasn't called... + if (mCouldHaveEvents) + NotifyObservers(gDestroyedNotification); PL_DestroyEventQueue(mEventQueue); } } @@ -236,6 +238,19 @@ nsEventQueueImpl::NotifyObservers(const char *aTopic) } } +void +nsEventQueueImpl::CheckForDeactivation() +{ + if (mCouldHaveEvents && !mAcceptingEvents && !PL_EventAvailable(mEventQueue)) { + if (PL_IsQueueOnCurrentThread(mEventQueue)) { + mCouldHaveEvents = PR_FALSE; + NotifyObservers(gDestroyedNotification); + NS_RELEASE_THIS(); // balance ADDREF from the constructor + } else + NS_ERROR("CheckForDeactivation called from wrong thread!"); + } +} + NS_IMETHODIMP nsEventQueueImpl::InitEvent(PLEvent* aEvent, diff --git a/mozilla/xpcom/threads/nsEventQueue.h b/mozilla/xpcom/threads/nsEventQueue.h index 51f33e478e4..7660e331a8b 100644 --- a/mozilla/xpcom/threads/nsEventQueue.h +++ b/mozilla/xpcom/threads/nsEventQueue.h @@ -75,15 +75,5 @@ private: nsPIEventQueueChain *mYoungerQueue; // but elder can't hold on to younger void NotifyObservers(const char *aTopic); - - void CheckForDeactivation() { - if (mCouldHaveEvents && !mAcceptingEvents && !PL_EventAvailable(mEventQueue)) { - if (PL_IsQueueOnCurrentThread(mEventQueue)) { - mCouldHaveEvents = PR_FALSE; - NS_RELEASE_THIS(); // balance ADDREF from the constructor - } else - NS_ERROR("CheckForDeactivation called from wrong thread!"); - } - } + void CheckForDeactivation(); }; -