From ffa546bdb875d9c4d07f7866e7f4e6e7ca5abfde Mon Sep 17 00:00:00 2001 From: "kin%netscape.com" Date: Fri, 28 May 1999 21:49:24 +0000 Subject: [PATCH] Fixed double addref in EnableUndo() that was causing us to leak the transaction manager on destruction of the editor. git-svn-id: svn://10.0.0.236/trunk@33158 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsEditor.cpp | 6 ++---- mozilla/editor/libeditor/base/nsEditor.cpp | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 98fbda793d5..3f6df3cb8c9 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -472,7 +472,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) NS_IMETHODIMP nsEditor::EnableUndo(PRBool aEnable) { - nsITransactionManager *txnMgr = 0; nsresult result=NS_OK; if (PR_TRUE==aEnable) @@ -481,12 +480,11 @@ nsEditor::EnableUndo(PRBool aEnable) { result = gCompMgr->CreateInstance(kCTransactionManagerCID, nsnull, - nsITransactionManager::GetIID(), (void **)&txnMgr); - if (NS_FAILED(result) || !txnMgr) { + nsITransactionManager::GetIID(), getter_AddRefs(mTxnMgr)); + if (NS_FAILED(result) || !mTxnMgr) { printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; } - mTxnMgr = do_QueryInterface(txnMgr); // CreateInstance refCounted the instance for us, remember it in an nsCOMPtr #ifdef DEBUG_WITH_JS_EDITOR_LOG nsJSEditorLog *log = new nsJSEditorLog(); diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 98fbda793d5..3f6df3cb8c9 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -472,7 +472,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) NS_IMETHODIMP nsEditor::EnableUndo(PRBool aEnable) { - nsITransactionManager *txnMgr = 0; nsresult result=NS_OK; if (PR_TRUE==aEnable) @@ -481,12 +480,11 @@ nsEditor::EnableUndo(PRBool aEnable) { result = gCompMgr->CreateInstance(kCTransactionManagerCID, nsnull, - nsITransactionManager::GetIID(), (void **)&txnMgr); - if (NS_FAILED(result) || !txnMgr) { + nsITransactionManager::GetIID(), getter_AddRefs(mTxnMgr)); + if (NS_FAILED(result) || !mTxnMgr) { printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; } - mTxnMgr = do_QueryInterface(txnMgr); // CreateInstance refCounted the instance for us, remember it in an nsCOMPtr #ifdef DEBUG_WITH_JS_EDITOR_LOG nsJSEditorLog *log = new nsJSEditorLog();