From c8afb22653b656c62cb0a1be8c21f70dd5cef259 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Mon, 14 Mar 2005 06:37:01 +0000 Subject: [PATCH] fixes bug 279852 "nsWeakReference not threadsafe assertions due to TimerThread::Init" r=sfraser sr=bryner git-svn-id: svn://10.0.0.236/trunk@170623 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/TimerThread.cpp | 14 ++++---------- mozilla/xpcom/threads/TimerThread.h | 5 +---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/mozilla/xpcom/threads/TimerThread.cpp b/mozilla/xpcom/threads/TimerThread.cpp index 9407689229e..a6d87ba2d88 100644 --- a/mozilla/xpcom/threads/TimerThread.cpp +++ b/mozilla/xpcom/threads/TimerThread.cpp @@ -47,7 +47,7 @@ #include "nsIObserverService.h" #include "nsIServiceManager.h" -NS_IMPL_THREADSAFE_ISUPPORTS3(TimerThread, nsIRunnable, nsISupportsWeakReference, nsIObserver) +NS_IMPL_THREADSAFE_ISUPPORTS2(TimerThread, nsIRunnable, nsIObserver) TimerThread::TimerThread() : mInitInProgress(0), @@ -77,13 +77,6 @@ TimerThread::~TimerThread() nsTimerImpl *timer = NS_STATIC_CAST(nsTimerImpl *, mTimers[n]); NS_RELEASE(timer); } - - nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); - if (observerService) { - observerService->RemoveObserver(this, "sleep_notification"); - observerService->RemoveObserver(this, "wake_notification"); - } - } nsresult @@ -131,8 +124,9 @@ nsresult TimerThread::Init() mThread = nsnull; } else { - observerService->AddObserver(this, "sleep_notification", PR_TRUE); - observerService->AddObserver(this, "wake_notification", PR_TRUE); + // We'll be released at xpcom shutdown + observerService->AddObserver(this, "sleep_notification", PR_FALSE); + observerService->AddObserver(this, "wake_notification", PR_FALSE); } } } diff --git a/mozilla/xpcom/threads/TimerThread.h b/mozilla/xpcom/threads/TimerThread.h index fa23cfc9ab2..039eea68c5c 100644 --- a/mozilla/xpcom/threads/TimerThread.h +++ b/mozilla/xpcom/threads/TimerThread.h @@ -41,8 +41,6 @@ #ifndef TimerThread_h___ #define TimerThread_h___ -#include "nsWeakReference.h" - #include "nsIEventQueueService.h" #include "nsIObserver.h" #include "nsIRunnable.h" @@ -56,8 +54,7 @@ #include "prinrval.h" #include "prlock.h" -class TimerThread : public nsSupportsWeakReference, - public nsIRunnable, +class TimerThread : public nsIRunnable, public nsIObserver { public: