Fix for leaks. Bug 48126 r=dbaron, hyatt

git-svn-id: svn://10.0.0.236/trunk@76074 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
saari%netscape.com
2000-08-11 02:11:53 +00:00
parent adc94749ec
commit d94289754b
4 changed files with 8 additions and 8 deletions

View File

@@ -826,9 +826,7 @@ nsImageMap::~nsImageMap()
FreeAreas();
if (nsnull != mDocument) {
mDocument->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
NS_RELEASE(mDocument);
}
NS_IF_RELEASE(mDomMap);
NS_IF_RELEASE(mMap);
}
@@ -877,13 +875,15 @@ nsImageMap::Init(nsIDOMHTMLMapElement* aMap)
return NS_ERROR_NULL_POINTER;
}
mDomMap = aMap;
NS_ADDREF(aMap);
nsresult rv = aMap->QueryInterface(kIContentIID, (void**) &mMap);
if (NS_SUCCEEDED(rv)) {
rv = mMap->GetDocument(mDocument);
if (NS_SUCCEEDED(rv) && (nsnull != mDocument)) {
mDocument->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
// mDocument is a weak reference, so release the reference we got
nsIDocument *temp = mDocument;
NS_RELEASE(temp);
}
}

View File

@@ -150,7 +150,7 @@ protected:
nsresult ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus);
nsresult Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& aRect);
nsIDocument* mDocument;
nsIDocument* mDocument; // WEAK - the imagemap will not outlive the document
nsIDOMHTMLMapElement* mDomMap;
nsIContent* mMap;
nsVoidArray mAreas;

View File

@@ -826,9 +826,7 @@ nsImageMap::~nsImageMap()
FreeAreas();
if (nsnull != mDocument) {
mDocument->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
NS_RELEASE(mDocument);
}
NS_IF_RELEASE(mDomMap);
NS_IF_RELEASE(mMap);
}
@@ -877,13 +875,15 @@ nsImageMap::Init(nsIDOMHTMLMapElement* aMap)
return NS_ERROR_NULL_POINTER;
}
mDomMap = aMap;
NS_ADDREF(aMap);
nsresult rv = aMap->QueryInterface(kIContentIID, (void**) &mMap);
if (NS_SUCCEEDED(rv)) {
rv = mMap->GetDocument(mDocument);
if (NS_SUCCEEDED(rv) && (nsnull != mDocument)) {
mDocument->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
// mDocument is a weak reference, so release the reference we got
nsIDocument *temp = mDocument;
NS_RELEASE(temp);
}
}

View File

@@ -150,7 +150,7 @@ protected:
nsresult ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus);
nsresult Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& aRect);
nsIDocument* mDocument;
nsIDocument* mDocument; // WEAK - the imagemap will not outlive the document
nsIDOMHTMLMapElement* mDomMap;
nsIContent* mMap;
nsVoidArray mAreas;