diff --git a/editor/composer/nsComposerCommandsUpdater.cpp b/editor/composer/nsComposerCommandsUpdater.cpp index 5edb1b7af032..dbb8b04a5ff2 100644 --- a/editor/composer/nsComposerCommandsUpdater.cpp +++ b/editor/composer/nsComposerCommandsUpdater.cpp @@ -385,9 +385,7 @@ nsComposerCommandsUpdater::Notify(nsITimer *timer) nsresult NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult) { - nsComposerCommandsUpdater* newThang = new nsComposerCommandsUpdater; - NS_ENSURE_TRUE(newThang, NS_ERROR_OUT_OF_MEMORY); - - return newThang->QueryInterface(NS_GET_IID(nsISelectionListener), - (void **)aInstancePtrResult); + nsRefPtr newThang = new nsComposerCommandsUpdater; + newThang.forget(aInstancePtrResult); + return NS_OK; } diff --git a/editor/libeditor/nsHTMLURIRefObject.cpp b/editor/libeditor/nsHTMLURIRefObject.cpp index 643a53639f76..809d8f15ffeb 100644 --- a/editor/libeditor/nsHTMLURIRefObject.cpp +++ b/editor/libeditor/nsHTMLURIRefObject.cpp @@ -254,7 +254,7 @@ nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode) *aResult = 0; return rv; } - return refObject->QueryInterface(NS_GET_IID(nsIURIRefObject), - (void**)aResult); + refObject.forget(aResult); + return NS_OK; } diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp index 02747b018c0f..32379cb44b70 100644 --- a/editor/txtsvc/nsTextServicesDocument.cpp +++ b/editor/txtsvc/nsTextServicesDocument.cpp @@ -2000,7 +2000,7 @@ nsTextServicesDocument::GetDocumentContentRootNode(nsIDOMNode **aNode) NS_ENSURE_TRUE(bodyElement, NS_ERROR_FAILURE); - result = bodyElement->QueryInterface(NS_GET_IID(nsIDOMNode), (void **)aNode); + bodyElement.forget(aNode); } else { @@ -2014,7 +2014,7 @@ nsTextServicesDocument::GetDocumentContentRootNode(nsIDOMNode **aNode) NS_ENSURE_TRUE(docElement, NS_ERROR_FAILURE); - result = docElement->QueryInterface(NS_GET_IID(nsIDOMNode), (void **)aNode); + docElement.forget(aNode); } return result; diff --git a/embedding/components/commandhandler/nsCommandGroup.cpp b/embedding/components/commandhandler/nsCommandGroup.cpp index 79057be10670..75851e8b888e 100644 --- a/embedding/components/commandhandler/nsCommandGroup.cpp +++ b/embedding/components/commandhandler/nsCommandGroup.cpp @@ -288,10 +288,10 @@ nsControllerCommandGroup::IsCommandInGroup(const char *aCommand, const char *aGr NS_IMETHODIMP nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator **_retval) { - nsGroupsEnumerator *groupsEnum = new nsGroupsEnumerator(mGroupsHash); - if (!groupsEnum) return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr groupsEnum = new nsGroupsEnumerator(mGroupsHash); - return groupsEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)_retval); + groupsEnum.forget(_retval); + return NS_OK; } /* nsISimpleEnumerator getEnumeratorForGroup (in DOMString aGroup); */ @@ -301,10 +301,10 @@ nsControllerCommandGroup::GetEnumeratorForGroup(const char *aGroup, nsISimpleEnu nsDependentCString groupKey(aGroup); nsTArray *commandList = mGroupsHash.Get(groupKey); // may be null - nsNamedGroupEnumerator *theGroupEnum = new nsNamedGroupEnumerator(commandList); - if (!theGroupEnum) return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr theGroupEnum = new nsNamedGroupEnumerator(commandList); - return theGroupEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)_retval); + theGroupEnum.forget(_retval); + return NS_OK; } #if 0 diff --git a/embedding/components/find/nsWebBrowserFind.cpp b/embedding/components/find/nsWebBrowserFind.cpp index c6d2df66e993..0ed92d4504c1 100644 --- a/embedding/components/find/nsWebBrowserFind.cpp +++ b/embedding/components/find/nsWebBrowserFind.cpp @@ -409,8 +409,8 @@ nsresult nsWebBrowserFind::GetRootNode(nsIDOMDocument* aDomDoc, rv = htmlDoc->GetBody(getter_AddRefs(bodyElement)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_ARG_POINTER(bodyElement); - return bodyElement->QueryInterface(NS_GET_IID(nsIDOMNode), - (void **)aNode); + bodyElement.forget(aNode); + return NS_OK; } // For non-HTML documents, the content root node will be the doc element. @@ -418,7 +418,8 @@ nsresult nsWebBrowserFind::GetRootNode(nsIDOMDocument* aDomDoc, rv = aDomDoc->GetDocumentElement(getter_AddRefs(docElement)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_ARG_POINTER(docElement); - return docElement->QueryInterface(NS_GET_IID(nsIDOMNode), (void **)aNode); + docElement.forget(aNode); + return NS_OK; } nsresult nsWebBrowserFind::SetRangeAroundDocument(nsIDOMRange* aSearchRange, diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index e9299ddaf51c..cdcd29a65651 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -651,9 +651,8 @@ nsStringBundleService::CreateExtensibleBundle(const char* aCategory, return res; } - res = bundle->QueryInterface(NS_GET_IID(nsIStringBundle), (void**) aResult); - - return res; + bundle.forget(aResult); + return NS_OK; } #define GLOBAL_PROPERTIES "chrome://global/locale/global-strres.properties" diff --git a/security/manager/ssl/src/PSMContentListener.cpp b/security/manager/ssl/src/PSMContentListener.cpp index 5ad7e5172c30..0526df885634 100644 --- a/security/manager/ssl/src/PSMContentListener.cpp +++ b/security/manager/ssl/src/PSMContentListener.cpp @@ -270,17 +270,13 @@ PSMContentListener::DoContent(const nsACString & aContentType, nsIStreamListener ** aContentHandler, bool * aAbortProcess) { - PSMContentDownloader *downLoader; uint32_t type; type = getPSMContentType(PromiseFlatCString(aContentType).get()); PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("PSMContentListener::DoContent\n")); if (type != PSMContentDownloader::UNKNOWN_TYPE) { - downLoader = new PSMContentDownloader(type); - if (downLoader) { - downLoader->QueryInterface(NS_GET_IID(nsIStreamListener), - (void **)aContentHandler); - return NS_OK; - } + nsRefPtr downLoader = new PSMContentDownloader(type); + downLoader.forget(aContentHandler); + return NS_OK; } return NS_ERROR_FAILURE; } diff --git a/toolkit/components/places/nsNavHistoryResult.cpp b/toolkit/components/places/nsNavHistoryResult.cpp index 7014997fed1a..356625baa429 100644 --- a/toolkit/components/places/nsNavHistoryResult.cpp +++ b/toolkit/components/places/nsNavHistoryResult.cpp @@ -4323,8 +4323,9 @@ nsNavHistoryResult::GetRoot(nsINavHistoryContainerResultNode** aRoot) *aRoot = nullptr; return NS_ERROR_FAILURE; } - return mRootNode->QueryInterface(NS_GET_IID(nsINavHistoryContainerResultNode), - reinterpret_cast(aRoot)); + nsRefPtr node(mRootNode); + node.forget(aRoot); + return NS_OK; } diff --git a/widget/nsPrintSettingsImpl.cpp b/widget/nsPrintSettingsImpl.cpp index d7d59e0f2dd2..83dcbc533c26 100644 --- a/widget/nsPrintSettingsImpl.cpp +++ b/widget/nsPrintSettingsImpl.cpp @@ -1110,8 +1110,9 @@ nsPrintSettings::GetPageRanges(nsTArray &aPages) nsresult nsPrintSettings::_Clone(nsIPrintSettings **_retval) { - nsPrintSettings* printSettings = new nsPrintSettings(*this); - return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts + nsRefPtr printSettings = new nsPrintSettings(*this); + printSettings.forget(_retval); + return NS_OK; } /* nsIPrintSettings clone (); */ diff --git a/widget/windows/nsImageClipboard.cpp b/widget/windows/nsImageClipboard.cpp index e3570f39dca4..fab62eab58cc 100644 --- a/widget/windows/nsImageClipboard.cpp +++ b/widget/windows/nsImageClipboard.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -251,8 +251,9 @@ nsImageFromClipboard ::GetEncodedImageStream (unsigned char * aClipboardData, co if (NS_SUCCEEDED(rv)){ rv = encoder->InitFromData(rgbData, 0, width, height, 3 * width /* RGB * # pixels in a row */, imgIEncoder::INPUT_FORMAT_RGB, EmptyString()); - if (NS_SUCCEEDED(rv)) - encoder->QueryInterface(NS_GET_IID(nsIInputStream), (void **) aInputStream); + if (NS_SUCCEEDED(rv)) { + encoder.forget(aInputStream); + } } } delete [] rgbData; diff --git a/widget/windows/nsPrintSettingsWin.cpp b/widget/windows/nsPrintSettingsWin.cpp index 782ba5eeb8b7..f9ed18ac3e92 100644 --- a/widget/windows/nsPrintSettingsWin.cpp +++ b/widget/windows/nsPrintSettingsWin.cpp @@ -118,8 +118,9 @@ NS_IMETHODIMP nsPrintSettingsWin::SetDevMode(DEVMODEW * aDevMode) nsresult nsPrintSettingsWin::_Clone(nsIPrintSettings **_retval) { - nsPrintSettingsWin* printSettings = new nsPrintSettingsWin(*this); - return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts + nsRefPtr printSettings = new nsPrintSettingsWin(*this); + printSettings.forget(_retval); + return NS_OK; } //------------------------------------------- diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index 44c634fa5fa9..c1eae8a17782 100644 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -228,7 +228,8 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent, } if (localFile && NS_SUCCEEDED(rv)) { - return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)aResult); + localFile.forget(aResult); + return NS_OK; } return rv; diff --git a/xpfe/appshell/nsWindowMediator.cpp b/xpfe/appshell/nsWindowMediator.cpp index 58cb387acec4..f9f513873459 100644 --- a/xpfe/appshell/nsWindowMediator.cpp +++ b/xpfe/appshell/nsWindowMediator.cpp @@ -195,11 +195,9 @@ nsWindowMediator::GetEnumerator(const char16_t* inType, nsISimpleEnumerator** ou NS_ENSURE_ARG_POINTER(outEnumerator); NS_ENSURE_STATE(mReady); - nsAppShellWindowEnumerator *enumerator = new nsASDOMWindowEarlyToLateEnumerator(inType, *this); - if (enumerator) - return enumerator->QueryInterface(NS_GET_IID(nsISimpleEnumerator) , (void**)outEnumerator); - - return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr enumerator = new nsASDOMWindowEarlyToLateEnumerator(inType, *this); + enumerator.forget(outEnumerator); + return NS_OK; } NS_IMETHODIMP @@ -209,11 +207,9 @@ nsWindowMediator::GetXULWindowEnumerator(const char16_t* inType, nsISimpleEnumer NS_ENSURE_ARG_POINTER(outEnumerator); NS_ENSURE_STATE(mReady); - nsAppShellWindowEnumerator *enumerator = new nsASXULWindowEarlyToLateEnumerator(inType, *this); - if (enumerator) - return enumerator->QueryInterface(NS_GET_IID(nsISimpleEnumerator) , (void**)outEnumerator); - - return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr enumerator = new nsASXULWindowEarlyToLateEnumerator(inType, *this); + enumerator.forget(outEnumerator); + return NS_OK; } NS_IMETHODIMP