diff --git a/base/src/mac/nsRepeater.cpp b/base/src/mac/nsRepeater.cpp index cbabf95d3873..5a93b4d29705 100644 --- a/base/src/mac/nsRepeater.cpp +++ b/base/src/mac/nsRepeater.cpp @@ -39,6 +39,7 @@ Repeater::~Repeater() // protected helper functs +//---------------------------------------------------------------------------- void Repeater::AddToRepeatList() { if (sRepeaters) @@ -48,6 +49,8 @@ void Repeater::AddToRepeatList() } sRepeaters = this; } + +//---------------------------------------------------------------------------- void Repeater::RemoveFromRepeatList() { if (sRepeaters == this) sRepeaters = mNextRptr; @@ -56,18 +59,22 @@ void Repeater::RemoveFromRepeatList() mPrevRptr = 0; mNextRptr = 0; } + +//---------------------------------------------------------------------------- void Repeater::AddToIdleList() { - if (sRepeaters) + if (sIdlers) { - sRepeaters->mPrevIdlr = this; - mNextIdlr = sRepeaters; + sIdlers->mPrevIdlr = this; + mNextIdlr = sIdlers; } - sRepeaters = this; + sIdlers = this; } + +//---------------------------------------------------------------------------- void Repeater::RemoveFromIdleList() { - if (sRepeaters == this) sRepeaters = mNextIdlr; + if (sIdlers == this) sIdlers = mNextIdlr; if (mPrevIdlr) mPrevIdlr->mNextIdlr = mNextIdlr; if (mNextIdlr) mNextIdlr->mPrevIdlr = mPrevIdlr; mPrevIdlr = 0; @@ -75,6 +82,7 @@ void Repeater::RemoveFromIdleList() } // repeater methods +//---------------------------------------------------------------------------- void Repeater::StartRepeating() { diff --git a/base/src/mac/nsTimerMac.cpp b/base/src/mac/nsTimerMac.cpp index b1bea49f6668..e1f17eaa64ec 100644 --- a/base/src/mac/nsTimerMac.cpp +++ b/base/src/mac/nsTimerMac.cpp @@ -77,9 +77,23 @@ class TimerImpl : public nsITimer virtual void* GetClosure(); +#if DEBUG + enum { + eGoodTimerSignature = 'Barf', + eDeletedTimerSignature = 'oops' + }; + + Boolean IsGoodTimer() { return (mSignature == eGoodTimerSignature); } +#endif + private: // Calculates mFireTime too void SetDelaySelf( PRUint32 aDelay ); + +#if DEBUG + UInt32 mSignature; +#endif + }; #pragma mark class TimerPeriodical @@ -126,6 +140,7 @@ TimerImpl::TimerImpl() , mClosure(nsnull) , mDelay(0) , mFireTime(0) +, mSignature(eGoodTimerSignature) { NS_INIT_REFCNT(); } @@ -136,6 +151,7 @@ TimerImpl::~TimerImpl() { Cancel(); NS_IF_RELEASE(mCallbackObject); + mSignature = eDeletedTimerSignature; } //---------------------------------------------------------------------------------------- @@ -265,7 +281,10 @@ void TimerPeriodical::RepeatAction( const EventRecord &inMacEvent) while (iter != mTimers.end()) { - TimerImpl* timer = *iter; + TimerImpl* timer = *iter; + + NS_ASSERTION(timer->IsGoodTimer(), "Bad timer!"); + if (timer->GetFireTime() <= inMacEvent.when) { mTimers.erase(iter++);