From da6c66f6f956fc56d3ec97427a73358b592d41d3 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Thu, 15 Apr 1999 20:34:44 +0000 Subject: [PATCH] Fixed to handle destroy callbacks better to unwind connections to image lib git-svn-id: svn://10.0.0.236/trunk@27675 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/nsImageRequest.cpp | 18 ++++++++++++++++-- mozilla/gfx/src/nsImageRequest.h | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) 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;