Bug 736761 - Don't crash if images are discarded after XPCOM shutdown. r=joe

This commit is contained in:
Justin Lebar 2012-03-18 09:56:00 -04:00
Родитель c8ab4ee986
Коммит a66b9a3d50
1 изменённых файлов: 9 добавлений и 6 удалений

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

@ -153,12 +153,12 @@ DiscardTracker::Initialize()
// Create the timer.
sTimer = do_CreateInstance("@mozilla.org/timer;1");
// Read the timeout pref and start the timer.
ReloadTimeout();
// Mark us as initialized
sInitialized = true;
// Read the timeout pref and start the timer.
ReloadTimeout();
return NS_OK;
}
@ -194,9 +194,12 @@ DiscardTracker::ReloadTimeout()
nsresult
DiscardTracker::EnableTimer()
{
// Nothing to do if the timer's already on.
if (sTimerOn)
// Nothing to do if the timer's already on or we haven't yet been
// initialized. !sTimer probably means we've shut down, so just ignore that,
// too.
if (sTimerOn || !sInitialized || !sTimer)
return NS_OK;
sTimerOn = true;
// Activate the timer. Have it call us back in (sMinDiscardTimeoutMs / 2)
@ -215,7 +218,7 @@ void
DiscardTracker::DisableTimer()
{
// Nothing to do if the timer's already off.
if (!sTimerOn)
if (!sTimerOn || !sTimer)
return;
sTimerOn = false;