From 4a6b4ad40f18ac3fd100a8daefc0b4937b7ebfb6 Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Tue, 20 Mar 2001 02:23:42 +0000 Subject: [PATCH] fix the image cache problem with nsImageDocuments and add some more assertions git-svn-id: svn://10.0.0.236/trunk@89864 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpr0n/src/imgLoader.cpp | 8 +++----- mozilla/modules/libpr0n/src/imgRequest.cpp | 16 +++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mozilla/modules/libpr0n/src/imgLoader.cpp b/mozilla/modules/libpr0n/src/imgLoader.cpp index 6cb8d6b2eac..9f1b23658e4 100644 --- a/mozilla/modules/libpr0n/src/imgLoader.cpp +++ b/mozilla/modules/libpr0n/src/imgLoader.cpp @@ -200,7 +200,9 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb request = NS_REINTERPRET_CAST(imgRequest*, req.get()); NS_ADDREF(request); - +#ifdef MOZ_NEW_CACHE + ImageCache::Put(uri, request, getter_AddRefs(entry)); +#endif #ifdef MOZ_NEW_CACHE request->Init(channel, entry); @@ -208,10 +210,6 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb request->Init(channel, nsnull); #endif -#ifdef MOZ_NEW_CACHE - ImageCache::Put(uri, request, getter_AddRefs(entry)); -#endif - *listener = NS_STATIC_CAST(nsIStreamListener*, request); NS_IF_ADDREF(*listener); } diff --git a/mozilla/modules/libpr0n/src/imgRequest.cpp b/mozilla/modules/libpr0n/src/imgRequest.cpp index 0fbdcc7f9d3..efe6ddf629f 100644 --- a/mozilla/modules/libpr0n/src/imgRequest.cpp +++ b/mozilla/modules/libpr0n/src/imgRequest.cpp @@ -361,6 +361,8 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(imgIRequest *request, nsISupports *cx, /* void onStopFrame (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame); */ NS_IMETHODIMP imgRequest::OnStopFrame(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame) { + NS_ASSERTION(frame, "imgRequest::OnStopFrame called with NULL frame"); + LOG_SCOPE(gImgLog, "imgRequest::OnStopFrame"); PRInt32 i = -1; @@ -379,7 +381,6 @@ NS_IMETHODIMP imgRequest::OnStopFrame(imgIRequest *request, nsISupports *cx, gfx frame->GetAlphaDataLength(&alphaSize); mCacheEntry->SetDataSize(cacheSize + imageSize + alphaSize); - printf("%p size is %d\n", this, cacheSize + imageSize + alphaSize); } #endif @@ -561,10 +562,15 @@ NS_IMETHODIMP imgRequest::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt, PRInt32 count = mObservers.Count(); while (++i < count) { - imgIDecoderObserver *iob = NS_STATIC_CAST(imgIDecoderObserver*, mObservers[i]); - if (iob) { - nsCOMPtr ob(do_QueryInterface(iob)); - if (ob) ob->OnStopRequest(aRequest, ctxt, status, statusArg); + void *item = NS_STATIC_CAST(void *, mObservers[i]); + if (item) { + imgIDecoderObserver *iob = NS_STATIC_CAST(imgIDecoderObserver*, item); + if (iob) { + nsCOMPtr ob(do_QueryInterface(iob)); + if (ob) ob->OnStopRequest(aRequest, ctxt, status, statusArg); + } + } else { + NS_NOTREACHED("why did we get a null item ?"); } }