Bug 328344, action module elements leak, r=aaronr+doronr

git-svn-id: svn://10.0.0.236/trunk@191175 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
Olli.Pettay%helsinki.fi
2006-02-24 19:13:43 +00:00
parent c55998f38e
commit fbce22d79e
4 changed files with 21 additions and 10 deletions

View File

@@ -52,7 +52,7 @@
#define DEFERRED_REVALIDATE 0x04
#define DEFERRED_REFRESH 0x08
nsXFormsActionElement::nsXFormsActionElement()
nsXFormsActionElement::nsXFormsActionElement() : mElement(nsnull)
{
}
@@ -71,9 +71,14 @@ nsXFormsActionElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
nsresult rv = nsXFormsXMLVisualStub::OnCreated(aWrapper);
NS_ENSURE_SUCCESS(rv, rv);
rv = aWrapper->GetElementNode(getter_AddRefs(mElement));
NS_ENSURE_SUCCESS(rv, rv);
// It's ok to keep a weak pointer to mElement. mElement will have an
// owning reference to this object, so as long as we null out mElement in
// OnDestroyed, it will always be valid.
nsCOMPtr<nsIDOMElement> node;
aWrapper->GetElementNode(getter_AddRefs(node));
mElement = node;
NS_ASSERTION(mElement, "Wrapper is not an nsIDOMElement, we'll crash soon");
nsCOMPtr<nsIDOMDocument> domDoc;
mElement->GetOwnerDocument(getter_AddRefs(domDoc));
rv = domDoc->CreateElementNS(NS_LITERAL_STRING(NS_NAMESPACE_XHTML),

View File

@@ -60,9 +60,9 @@ public:
NS_IMETHOD GetInsertionPoint(nsIDOMElement **aElement);
NS_IMETHOD OnDestroyed();
private:
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIDOMElement> mVisualElement;
nsCOMPtr<nsIXFormsActionElement> mParentAction;
nsIDOMElement* mElement;
nsCOMPtr<nsIDOMElement> mVisualElement;
nsCOMPtr<nsIXFormsActionElement> mParentAction;
nsDataHashtable<nsISupportsHashKey,PRUint32> mDeferredUpdates;
};

View File

@@ -49,7 +49,7 @@
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMEventTarget.h"
nsXFormsActionModuleBase::nsXFormsActionModuleBase()
nsXFormsActionModuleBase::nsXFormsActionModuleBase() : mElement(nsnull)
{
}
@@ -65,7 +65,13 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsActionModuleBase,
NS_IMETHODIMP
nsXFormsActionModuleBase::OnCreated(nsIXTFGenericElementWrapper *aWrapper)
{
aWrapper->GetElementNode(getter_AddRefs(mElement));
// It's ok to keep a weak pointer to mElement. mElement will have an
// owning reference to this object, so as long as we null out mElement in
// OnDestroyed, it will always be valid.
nsCOMPtr<nsIDOMElement> node;
aWrapper->GetElementNode(getter_AddRefs(node));
mElement = node;
NS_ASSERTION(mElement, "Wrapper is not an nsIDOMElement, we'll crash soon");
return NS_OK;
}

View File

@@ -58,7 +58,7 @@ public:
NS_DECL_NSIDOMEVENTLISTENER
NS_IMETHOD OnDestroyed();
protected:
nsCOMPtr<nsIDOMElement> mElement;
nsIDOMElement* mElement;
};
#endif