Fixed bug #1159. Reference counting bug related to forms...

This commit is contained in:
rpotts%netscape.com 1998-10-21 09:26:33 +00:00
Родитель ed1c1a17a7
Коммит c8ca4c5060
2 изменённых файлов: 28 добавлений и 14 удалений

Просмотреть файл

@ -2199,17 +2199,23 @@ nsHTMLDocument::AddForm(nsIDOMHTMLFormElement *aForm)
if (nsnull == aForm) { if (nsnull == aForm) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
if (!mForms) {
nsIDOMHTMLCollection* forms = nsnull;
GetForms(&forms);
}
nsIContent* iContent = nsnull; nsIContent* iContent = nsnull;
nsresult result = aForm->QueryInterface(kIContentIID, (void**)&iContent); nsresult result = aForm->QueryInterface(kIContentIID, (void**)&iContent);
if ((NS_OK == result) && iContent) { if ((NS_OK == result) && iContent) {
if (mForms->Add(iContent)) { nsIDOMHTMLCollection* forms = nsnull;
NS_RELEASE(iContent);
return NS_OK; // Initialize mForms if necessary...
if (nsnull == mForms) {
nsIDOMHTMLCollection* forms = nsnull;
result = GetForms(&forms);
NS_IF_RELEASE(forms);
} }
if (NS_SUCCEEDED(result)) {
mForms->Add(iContent);
}
NS_RELEASE(iContent);
} }
return result; return result;
} }
@ -2223,6 +2229,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms)
if (nsnull == mForms) { if (nsnull == mForms) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
NS_ADDREF(mForms);
} }
*aForms = (nsIDOMHTMLCollection *)mForms; *aForms = (nsIDOMHTMLCollection *)mForms;

Просмотреть файл

@ -2199,17 +2199,23 @@ nsHTMLDocument::AddForm(nsIDOMHTMLFormElement *aForm)
if (nsnull == aForm) { if (nsnull == aForm) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
if (!mForms) {
nsIDOMHTMLCollection* forms = nsnull;
GetForms(&forms);
}
nsIContent* iContent = nsnull; nsIContent* iContent = nsnull;
nsresult result = aForm->QueryInterface(kIContentIID, (void**)&iContent); nsresult result = aForm->QueryInterface(kIContentIID, (void**)&iContent);
if ((NS_OK == result) && iContent) { if ((NS_OK == result) && iContent) {
if (mForms->Add(iContent)) { nsIDOMHTMLCollection* forms = nsnull;
NS_RELEASE(iContent);
return NS_OK; // Initialize mForms if necessary...
if (nsnull == mForms) {
nsIDOMHTMLCollection* forms = nsnull;
result = GetForms(&forms);
NS_IF_RELEASE(forms);
} }
if (NS_SUCCEEDED(result)) {
mForms->Add(iContent);
}
NS_RELEASE(iContent);
} }
return result; return result;
} }
@ -2223,6 +2229,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms)
if (nsnull == mForms) { if (nsnull == mForms) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
NS_ADDREF(mForms);
} }
*aForms = (nsIDOMHTMLCollection *)mForms; *aForms = (nsIDOMHTMLCollection *)mForms;