Bug 803853, make sure to not leak mRules, r=ehsan

This commit is contained in:
Olli Pettay 2012-12-07 01:31:48 +02:00
parent ba6b429800
commit 3243bf0a89
3 changed files with 9 additions and 0 deletions

View File

@ -274,6 +274,9 @@ nsHTMLEditRules::Init(nsPlaintextEditor *aEditor)
NS_IMETHODIMP
nsHTMLEditRules::DetachEditor()
{
if (mHTMLEditor) {
mHTMLEditor->RemoveEditActionListener(this);
}
mHTMLEditor = nullptr;
return nsTextEditRules::DetachEditor();
}

View File

@ -484,6 +484,7 @@ nsHTMLEditor::SetFlags(uint32_t aFlags)
NS_IMETHODIMP
nsHTMLEditor::InitRules()
{
MOZ_ASSERT(!mRules);
// instantiate the rules for the html editor
mRules = new nsHTMLEditRules();
return mRules->Init(static_cast<nsPlaintextEditor*>(this));

View File

@ -121,6 +121,10 @@ NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
nsresult res = NS_OK, rulesRes = NS_OK;
if (mRules) {
mRules->DetachEditor();
mRules = nullptr;
}
if (1)
{
@ -313,6 +317,7 @@ nsPlaintextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument,
NS_IMETHODIMP nsPlaintextEditor::InitRules()
{
MOZ_ASSERT(!mRules);
// instantiate the rules for this text editor
mRules = new nsTextEditRules();
return mRules->Init(this);