diff --git a/mozilla/gfx/src/nsImageRequest.cpp b/mozilla/gfx/src/nsImageRequest.cpp index 0cfd903d73a..b304b94c6c4 100644 --- a/mozilla/gfx/src/nsImageRequest.cpp +++ b/mozilla/gfx/src/nsImageRequest.cpp @@ -125,7 +125,9 @@ nsrefcnt ImageRequestImpl::Release(void) // Make sure dangling reference to this object goes away XP_RemoveObserver(mXPObserver, ns_observer_proc, (void*)this); } - IL_DestroyImage(mImageReq); + if (mImageReq) { + IL_DestroyImage(mImageReq); + } NS_DELETEXPCOM(this); return 0; } @@ -346,7 +348,19 @@ static void ns_observer_proc (XP_Observable aSource, */ if ((IL_IMAGE_DESTROYED == aMsg) && (nsnull != image_request)) { image_request->SetImageRequest(nsnull); + image_request->ImageDestroyed(); } } - +void +ImageRequestImpl::ImageDestroyed() +{ + if (mXPObserver) { + // Make sure dangling reference to this object goes + // away; this is just in case the image library changes + // and holds onto the observer list after destroying the + // image. + XP_RemoveObserver(mXPObserver, ns_observer_proc, (void*)this); + mXPObserver = nsnull; + } +} diff --git a/mozilla/gfx/src/nsImageRequest.h b/mozilla/gfx/src/nsImageRequest.h index d85a5f5ac0d..2c01c567e02 100644 --- a/mozilla/gfx/src/nsImageRequest.h +++ b/mozilla/gfx/src/nsImageRequest.h @@ -58,10 +58,13 @@ public: // Interrupt loading of just this image. virtual void Interrupt(); + // XXX These should go: fix ns_observer_proc to be a static method IL_ImageReq *GetImageRequest() { return mImageReq; } void SetImageRequest(IL_ImageReq *aImageReq) { mImageReq = aImageReq; } nsVoidArray *GetObservers() { return mObservers; } + void ImageDestroyed(); + private: IL_ImageReq *mImageReq; IL_GroupContext *mGroupContext;