PHOTON ONLY: Added a Kung Foo Deathgrip to the Timer Event handler

so the timer could not be destroyed while inside the callback. I
did it just like GTK did it. It was crashing at http://www.uescape.com
This commit is contained in:
Jerry.Kirk%Nexwarecorp.com 2000-11-08 13:54:15 +00:00
Родитель 49ab1ee935
Коммит 4a2bfa50ee
1 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -214,23 +214,23 @@ nsTimerPh::Cancel()
int nsTimerPh::TimerEventHandler( void *aData, pid_t aRcvId, void *aMsg, size_t aMsgLen )
{
int localTimerId;
nsTimerPh* timer = (nsTimerPh *)aData;
if( timer )
{
localTimerId = timer->mTimerId;
if( timer->mFunc != NULL )
{
(*timer->mFunc)( timer, timer->mClosure );
}
else if ( timer->mCallback != NULL )
{
timer->mCallback->Notify( timer );
}
/* These stupid people destroy this object inside the callback */
/* so don't do anything with it from here on */
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::TimerEventHandler this=<%p>\n", aData));
NS_ASSERTION(timer, "nsTimerPh::TimerEventHandler is NULL!");
// because Notify can cause 'timer' to get destroyed, we need to hold a ref
nsCOMPtr<nsITimer> kungFuDeathGrip = timer;
localTimerId = timer->mTimerId;
if( timer->mFunc != NULL )
{
(*timer->mFunc)( timer, timer->mClosure );
}
else if ( timer->mCallback != NULL )
{
timer->mCallback->Notify( timer );
}
return Pt_CONTINUE;