Make the IconLoad hold a ref to the image listener. Fixes race to a crash.

Bug 199021, r=pavlov, sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2003-04-02 01:35:20 +00:00
Родитель cf91cfe654
Коммит 19d7284dc8
4 изменённых файлов: 12 добавлений и 8 удалений

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

@ -320,8 +320,8 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
PRBool loadBlocked = PR_FALSE;
imageLoader->GetImageBlocked(&loadBlocked);
rv = loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE;
HandleLoadError(rv, presShell);
HandleLoadError(loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE,
presShell);
}
return rv;
@ -1902,7 +1902,7 @@ nsresult nsImageFrame::LoadIcons(nsIPresContext *aPresContext)
#ifdef NOISY_ICON_LOADING
printf( "Allocating IconLoad (%p)\n", this);
#endif
mIconLoad = new IconLoad(aPresContext);
mIconLoad = new IconLoad(aPresContext, mListener);
if (!mIconLoad)
return NS_ERROR_OUT_OF_MEMORY;
doLoad = PR_TRUE;

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

@ -277,8 +277,9 @@ private:
// private class that wraps the data and logic needed for
// broken image and loading image icons
public:
IconLoad(nsIPresContext *aPresContext)
IconLoad(nsIPresContext *aPresContext, imgIDecoderObserver* aObserver)
: mRefCount(0),
mLoadObserver(aObserver),
mIconsLoaded(PR_FALSE)
{
GetPrefs(aPresContext);
@ -306,6 +307,7 @@ private:
#define NS_ICON_BROKEN_IMAGE (1)
public:
struct SingleIconLoad mIconLoads[2];
nsCOMPtr<imgIDecoderObserver> mLoadObserver; // keeps the observer alive
PRPackedBool mIconsLoaded;
PRPackedBool mPrefForceInlineAltText;
PRPackedBool mPrefAllImagesBlocked;

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

@ -320,8 +320,8 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
PRBool loadBlocked = PR_FALSE;
imageLoader->GetImageBlocked(&loadBlocked);
rv = loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE;
HandleLoadError(rv, presShell);
HandleLoadError(loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE,
presShell);
}
return rv;
@ -1902,7 +1902,7 @@ nsresult nsImageFrame::LoadIcons(nsIPresContext *aPresContext)
#ifdef NOISY_ICON_LOADING
printf( "Allocating IconLoad (%p)\n", this);
#endif
mIconLoad = new IconLoad(aPresContext);
mIconLoad = new IconLoad(aPresContext, mListener);
if (!mIconLoad)
return NS_ERROR_OUT_OF_MEMORY;
doLoad = PR_TRUE;

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

@ -277,8 +277,9 @@ private:
// private class that wraps the data and logic needed for
// broken image and loading image icons
public:
IconLoad(nsIPresContext *aPresContext)
IconLoad(nsIPresContext *aPresContext, imgIDecoderObserver* aObserver)
: mRefCount(0),
mLoadObserver(aObserver),
mIconsLoaded(PR_FALSE)
{
GetPrefs(aPresContext);
@ -306,6 +307,7 @@ private:
#define NS_ICON_BROKEN_IMAGE (1)
public:
struct SingleIconLoad mIconLoads[2];
nsCOMPtr<imgIDecoderObserver> mLoadObserver; // keeps the observer alive
PRPackedBool mIconsLoaded;
PRPackedBool mPrefForceInlineAltText;
PRPackedBool mPrefAllImagesBlocked;