From 1e3ed80af606bbbf8a52108f6fedabbd881eddb3 Mon Sep 17 00:00:00 2001 From: "sayrer@gmail.com" Date: Tue, 30 Oct 2007 08:56:59 -0700 Subject: [PATCH] Bug 401137. Silence ASSERTION: RefreshURIList timer callbacks should only be RefreshTimer objects. Docshell expects to be able to getCallback during a Timer fire. r=bzbarsky, sr=brendan, a=mconnor --- xpcom/threads/nsTimerImpl.cpp | 5 +++++ xpcom/threads/nsTimerImpl.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index a06c185565e9..6629e5ef9c9d 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -338,6 +338,8 @@ NS_IMETHODIMP nsTimerImpl::GetCallback(nsITimerCallback **aCallback) { if (mCallbackType == CALLBACK_TYPE_INTERFACE) NS_IF_ADDREF(*aCallback = mCallback.i); + else if (mTimerCallbackWhileFiring) + NS_ADDREF(*aCallback = mTimerCallbackWhileFiring); else *aCallback = nsnull; @@ -379,6 +381,8 @@ void nsTimerImpl::Fire() if (gThread) gThread->UpdateFilter(mDelay, timeout, now); + if (mCallbackType == CALLBACK_TYPE_INTERFACE) + mTimerCallbackWhileFiring = mCallback.i; mFiring = PR_TRUE; // Handle callbacks that re-init the timer, but avoid leaking. @@ -420,6 +424,7 @@ void nsTimerImpl::Fire() } mFiring = PR_FALSE; + mTimerCallbackWhileFiring = nsnull; #ifdef DEBUG_TIMERS if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) { diff --git a/xpcom/threads/nsTimerImpl.h b/xpcom/threads/nsTimerImpl.h index daaea7fc6e50..98789b7cc74c 100644 --- a/xpcom/threads/nsTimerImpl.h +++ b/xpcom/threads/nsTimerImpl.h @@ -127,6 +127,10 @@ private: nsIObserver * o; } mCallback; + // Some callers expect to be able to access the callback while the + // timer is firing. + nsCOMPtr mTimerCallbackWhileFiring; + // These members are set by Init (called from NS_NewTimer) and never reset. PRUint8 mCallbackType;