Fixed circular ref counting problem that was keeping throbber from being

freed
This commit is contained in:
troy%netscape.com 1998-10-07 00:38:57 +00:00
Родитель b88cb9dffe
Коммит c6fb274af1
1 изменённых файлов: 9 добавлений и 5 удалений

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

@ -417,9 +417,15 @@ nsThrobber::Notify(nsIImageRequest *aImageRequest,
PRInt32 aParam1, PRInt32 aParam2, PRInt32 aParam1, PRInt32 aParam2,
void *aParam3) void *aParam3)
{ {
if (aNotificationType == nsImageNotification_kImageComplete) if (aNotificationType == nsImageNotification_kImageComplete) {
mCompletedImages++; mCompletedImages++;
// Remove ourselves as an observer of the image request object, because
// the image request objects each hold a reference to us. This avoids a
// circular reference problem. If we don't, our ref count will never reach
// 0 and we won't get destroyed and neither will the image request objects
aImageRequest->RemoveObserver((nsIImageRequestObserver*)this);
}
} }
void void
@ -491,8 +497,6 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages
mWidth - 2, mWidth - 2,
mHeight - 2, 0), mHeight - 2, 0),
cnt); cnt);
// Note: the throbber observer was created with a ref count of 0
// which is why we don't have to release a reference to it
} }
if (nsnull != mask) if (nsnull != mask)