From 8efe8bcc689291917b488d48b7cff9cc0e4e235c Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Mon, 13 Dec 1999 23:05:31 +0000 Subject: [PATCH] Added an assert and return so that eventQs only get processed on the owning thread. This fixes at least 18005 and 17065. r=damn@netscape.com, a=chofmann. git-svn-id: svn://10.0.0.236/trunk@55941 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/nsEventQueue.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mozilla/xpcom/threads/nsEventQueue.cpp b/mozilla/xpcom/threads/nsEventQueue.cpp index 580c577b88c..8fce8c61409 100644 --- a/mozilla/xpcom/threads/nsEventQueue.cpp +++ b/mozilla/xpcom/threads/nsEventQueue.cpp @@ -190,6 +190,10 @@ nsEventQueueImpl::IsQueueOnCurrentThread(PRBool *aResult) NS_IMETHODIMP nsEventQueueImpl::ProcessPendingEvents() { + PRBool correctThread = PL_IsQueueOnCurrentThread(mEventQueue); + NS_ASSERTION(correctThread, "attemping to process events on the wrong thread"); + if (!correctThread) + return NS_ERROR_FAILURE; PL_ProcessPendingEvents(mEventQueue); CheckForDeactivation(); return NS_OK; @@ -198,6 +202,11 @@ nsEventQueueImpl::ProcessPendingEvents() NS_IMETHODIMP nsEventQueueImpl::EventLoop() { + PRBool correctThread = PL_IsQueueOnCurrentThread(mEventQueue); + NS_ASSERTION(correctThread, "attemping to process events on the wrong thread"); + if (!correctThread) + return NS_ERROR_FAILURE; + PL_EventLoop(mEventQueue); return NS_OK; } @@ -220,6 +229,11 @@ nsEventQueueImpl::GetEvent(PLEvent** aResult) NS_IMETHODIMP nsEventQueueImpl::HandleEvent(PLEvent* aEvent) { + PRBool correctThread = PL_IsQueueOnCurrentThread(mEventQueue); + NS_ASSERTION(correctThread, "attemping to process events on the wrong thread"); + if (!correctThread) + return NS_ERROR_FAILURE; + PL_HandleEvent(aEvent); return NS_OK; } @@ -227,6 +241,11 @@ nsEventQueueImpl::HandleEvent(PLEvent* aEvent) NS_IMETHODIMP nsEventQueueImpl::WaitForEvent() { + PRBool correctThread = PL_IsQueueOnCurrentThread(mEventQueue); + NS_ASSERTION(correctThread, "attemping to process events on the wrong thread"); + if (!correctThread) + return NS_ERROR_FAILURE; + PL_WaitForEvent(mEventQueue); CheckForDeactivation(); return NS_OK;