From c04339b026b60ba752adc76e2f36d9efda19adcc Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Sat, 19 Jun 1999 22:08:49 +0000 Subject: [PATCH] Leak fixing. CreateNewTopLevel window returns an AddReffed window. You must release it. git-svn-id: svn://10.0.0.236/trunk@35931 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/compose/tests/compose/test.cpp | 4 ++-- .../mailnews/compose/tests/sendlater/test.cpp | 4 ++-- mozilla/xpfe/AppCores/src/nsToolkitCore.cpp | 17 +++++++---------- .../ucth/src/nsUnknownContentTypeHandler.cpp | 6 +++--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/mozilla/mailnews/compose/tests/compose/test.cpp b/mozilla/mailnews/compose/tests/compose/test.cpp index 4b9f5f50218..baee88f09a7 100644 --- a/mozilla/mailnews/compose/tests/compose/test.cpp +++ b/mozilla/mailnews/compose/tests/compose/test.cpp @@ -195,12 +195,12 @@ int main(int argc, char *argv[]) /* * Create the Application Shell instance... */ - nsIWebShellWindow* newWindow; + nsCOMPtr newWindow; rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID, (nsISupports**)&appShell); if (NS_SUCCEEDED(rv)) - appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, newWindow, + appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, *getter_AddRefs(newWindow), nsnull, nsnull, 200, 200); // Create the Event Queue for this thread... diff --git a/mozilla/mailnews/compose/tests/sendlater/test.cpp b/mozilla/mailnews/compose/tests/sendlater/test.cpp index 260b74ac785..f10619b061b 100644 --- a/mozilla/mailnews/compose/tests/sendlater/test.cpp +++ b/mozilla/mailnews/compose/tests/sendlater/test.cpp @@ -132,12 +132,12 @@ int main(int argc, char *argv[]) /* * Create the Application Shell instance... */ - nsIWebShellWindow* newWindow; + nsCOMPtr newWindow; rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID, (nsISupports**)&appShell); if (NS_SUCCEEDED(rv)) - appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, newWindow, + appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, *getter_AddRefs(newWindow), nsnull, nsnull, 200, 200); // Create the Event Queue for this thread... diff --git a/mozilla/xpfe/AppCores/src/nsToolkitCore.cpp b/mozilla/xpfe/AppCores/src/nsToolkitCore.cpp index b1fbcae8cfe..0065c3c0279 100644 --- a/mozilla/xpfe/AppCores/src/nsToolkitCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsToolkitCore.cpp @@ -185,9 +185,6 @@ NS_IMETHODIMP nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { nsresult rv; - nsIWebShellWindow *window; - - window = nsnull; nsCOMPtr urlObj; @@ -214,10 +211,11 @@ nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, window, + nsCOMPtr window; + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), nsnull, nsnull, 615, 480); - if (window != nsnull) + if (window) window->Show(PR_TRUE); return rv; @@ -310,9 +308,6 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl, const nsString& aArgs) { nsresult rv; - nsIWebShellWindow *window; - - window = nsnull; nsCOMPtr urlObj; #ifndef NECKO @@ -340,10 +335,12 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl, DOMWindowToWebShellWindow(aParent, &parent); nsCOMPtr cb; cb = nsDontQueryInterface( new nsArgCallbacks( aArgs ) ); - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, window, + + nsCOMPtr window; + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), nsnull, cb, 615, 650); - if (window != nsnull) + if (window) window->Show(PR_TRUE); return rv; diff --git a/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp b/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp index 668fe5294e5..5cbf73c11dc 100644 --- a/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp +++ b/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp @@ -202,7 +202,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIURL *aURL, // Make sure we've been initialized. if ( mAppShell ) { // Open "Unknown file type" dialog. - nsIWebShellWindow *newWindow; + nsCOMPtr newWindow; // Make url for dialog xul. nsIURL *url; @@ -228,7 +228,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIURL *aURL, rv = mAppShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - newWindow, + *getter_AddRefs(newWindow), nsnull, dialog, 0, 0 ); @@ -247,7 +247,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIURL *aURL, return rv; } -#ifdef NS_DEBUG +#if defined( NS_DEBUG ) && !defined( XP_MAC ) #define DEBUG_PRINTF PR_fprintf #else #define DEBUG_PRINTF (void)