Fixed to handle destroy callbacks better to unwind connections to image lib

This commit is contained in:
kipp%netscape.com 1999-04-15 20:34:44 +00:00
parent 6305617dfe
commit b556d2e592
2 changed files with 19 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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;