Leak fixing. CreateNewTopLevel window returns an AddReffed window. You must release it.

This commit is contained in:
sfraser%netscape.com 1999-06-19 21:53:00 +00:00
Родитель d39d6eef11
Коммит f33ad6edc1
8 изменённых файлов: 34 добавлений и 1136 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -463,13 +463,13 @@ nsDOMPropsCore::ShowProperties(const nsString& aUrl, nsIDOMWindow* aParent, nsID
if (NS_FAILED(rv))
return rv;
nsIWebShellWindow *newWindow;
nsPropertiesDialog *dialog = new nsPropertiesDialog(aNode);
nsCOMPtr<nsIWebShellWindow> parent = DOMWindowToWebShellWindow(aParent);
rv = appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, newWindow,
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(newWindow),
nsnull, dialog, 450, 240);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);

Просмотреть файл

@ -536,7 +536,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil
// Another way, but this way loads the URL as the "chrome" - no toolbar, etc.
// Personally, I like this better, but it's not "right" :-)
nsIWebShellWindow* aWindow = FindWebShellWindow(nsnull);
nsCOMPtr<nsIWebShellWindow> aWindow = getter_AddRefs(FindWebShellWindow(nsnull));
if (!aWindow)
return errAEEventNotHandled;
@ -760,7 +760,7 @@ Clean:
// evaluate the javascript till after javascript is initialized.
// nsCOMPtr<nsJavascriptCallbacks> cb(
// nsDontQueryInterface<nsJavascriptCallbacks>(new nsJavascriptCallbacks(scriptText)));
nsIWebShellWindow* aWindow = FindWebShellWindow(nsnull);
nsCOMPtr<nsIWebShellWindow> aWindow = getter_AddRefs(FindWebShellWindow(nsnull));
if (!aWindow)
return errAEEventNotHandled;
@ -971,6 +971,7 @@ OSErr nsAppleEventHandler::SetAEProperty(DescType inProperty,
}
//----------------------------------------------------------------------------------------
// The return value has been AddRefed. Callers should release it.
nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
//----------------------------------------------------------------------------------------
{
@ -980,7 +981,6 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
if (NS_FAILED(rv))
return nsnull;
nsIWebShellWindow* aWindow;
const PRInt32 windowWidth = 615;
const PRInt32 windowHeight = 650;
nsCOMPtr<nsIURL> urlObj;
@ -1000,6 +1000,8 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
#endif // NECKO
if (NS_FAILED(rv))
return nsnull;
nsIWebShellWindow *aWindow = nsnull; // we will return the window AddRefed
rv = appShellService->CreateTopLevelWindow(
nsnull,
urlObj, // nsIURL* of chrome

Просмотреть файл

@ -26,6 +26,7 @@
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsIWidget.h"
#include "nsIWebShellWindow.h"
#include "nsIPref.h"
#include "plevent.h"
#include "prmem.h"
@ -258,7 +259,7 @@ int main(int argc, char* argv[])
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
profileService->Startup(nsnull);
@ -276,14 +277,14 @@ int main(int argc, char* argv[])
(nsISupports **)&cmdLineArgs);
if (NS_FAILED(rv)) {
fprintf(stderr, "Could not obtain CmdLine processing service\n");
goto done;
goto done; // don't use goto in C++!
}
// Initialize the cmd line service
rv = cmdLineArgs->Initialize(argc, argv);
if (rv == NS_ERROR_INVALID_ARG) {
PrintUsage();
goto done;
goto done; // don't use goto in C++!
}
#if 0
@ -291,7 +292,7 @@ int main(int argc, char* argv[])
rv = cmdLineArgs->GetURLToLoad(&urlstr);
if (rv == NS_ERROR_INVALID_ARG) {
PrintUsage();
goto done;
goto done; // don't use goto in C++!
}
#endif /* 0 */
@ -445,7 +446,7 @@ int main(int argc, char* argv[])
// Get the value of -width option
rv = cmdLineArgs->GetCmdLineValue("-width", &width);
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
if (width) {
PR_sscanf(width, "%d", &widthVal);
@ -457,7 +458,7 @@ int main(int argc, char* argv[])
// Get the value of -height option
rv = cmdLineArgs->GetCmdLineValue("-height", &height);
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
if (height) {
PR_sscanf(height, "%d", &heightVal);
@ -473,7 +474,7 @@ int main(int argc, char* argv[])
nsIPref::GetIID(),
(nsISupports **)&prefs);
if (NS_FAILED(rv))
goto done;
goto done; // don't use goto in C++!
/*
* Create the Application Shell instance...
@ -482,7 +483,7 @@ int main(int argc, char* argv[])
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
/*
@ -490,7 +491,7 @@ int main(int argc, char* argv[])
*/
rv = appShell->Initialize( cmdLineArgs );
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
/*
@ -501,7 +502,6 @@ int main(int argc, char* argv[])
* deal with GUI initialization...
*/
///write me...
nsIWebShellWindow* newWindow;
#ifndef NECKO
rv = NS_NewURL(&url, urlstr);
@ -519,7 +519,7 @@ int main(int argc, char* argv[])
#endif // NECKO
if (NS_FAILED(rv)) {
goto done;
goto done; // don't use goto in C++!
}
/* ********************************************************************* */
@ -595,7 +595,6 @@ int main(int argc, char* argv[])
PRInt32 profWinWidth = 615;
PRInt32 profWinHeight = 500;
nsIWebShellWindow* profWindow;
nsIAppShellService* profAppShell;
/*
@ -628,7 +627,8 @@ int main(int argc, char* argv[])
goto done;
}
rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, PR_TRUE, profWindow,
nsCOMPtr<nsIWebShellWindow> profWindow;
rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, PR_TRUE, *getter_AddRefs(profWindow),
nsnull, nsnull, profWinWidth, profWinHeight);
NS_RELEASE(profURL);
@ -656,7 +656,8 @@ int main(int argc, char* argv[])
goto done;
if ( !useArgs ) {
rv = appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, newWindow,
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow),
nsnull, nsnull, widthVal, heightVal);
} else {
nsIDOMToolkitCore* toolkit = nsnull;
@ -664,7 +665,6 @@ int main(int argc, char* argv[])
nsIDOMToolkitCore::GetIID(),
(nsISupports**)&toolkit);
if (NS_SUCCEEDED(rv)) {
nsIWebShellWindow* newWindow = nsnull;
toolkit->ShowWindowWithArgs( urlstr, nsnull, withArgs );

Просмотреть файл

@ -631,7 +631,6 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind)
Context *context = (Context*)aContext;
// Open Find dialog and prompt for search parameters.
nsIWebShellWindow *newWindow;
// Make url for dialog xul.
nsIURL *url;
@ -657,10 +656,11 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind)
// Create callbacks object for the find dialog.
nsFindDialog *dialog = new nsFindDialog( this, context );
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = mAppShell->CreateTopLevelWindow( nsnull,
url,
PR_TRUE,
newWindow,
*getter_AddRefs(newWindow),
nsnull,
dialog,
0,

Просмотреть файл

@ -536,7 +536,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil
// Another way, but this way loads the URL as the "chrome" - no toolbar, etc.
// Personally, I like this better, but it's not "right" :-)
nsIWebShellWindow* aWindow = FindWebShellWindow(nsnull);
nsCOMPtr<nsIWebShellWindow> aWindow = getter_AddRefs(FindWebShellWindow(nsnull));
if (!aWindow)
return errAEEventNotHandled;
@ -760,7 +760,7 @@ Clean:
// evaluate the javascript till after javascript is initialized.
// nsCOMPtr<nsJavascriptCallbacks> cb(
// nsDontQueryInterface<nsJavascriptCallbacks>(new nsJavascriptCallbacks(scriptText)));
nsIWebShellWindow* aWindow = FindWebShellWindow(nsnull);
nsCOMPtr<nsIWebShellWindow> aWindow = getter_AddRefs(FindWebShellWindow(nsnull));
if (!aWindow)
return errAEEventNotHandled;
@ -971,6 +971,7 @@ OSErr nsAppleEventHandler::SetAEProperty(DescType inProperty,
}
//----------------------------------------------------------------------------------------
// The return value has been AddRefed. Callers should release it.
nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
//----------------------------------------------------------------------------------------
{
@ -980,7 +981,6 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
if (NS_FAILED(rv))
return nsnull;
nsIWebShellWindow* aWindow;
const PRInt32 windowWidth = 615;
const PRInt32 windowHeight = 650;
nsCOMPtr<nsIURL> urlObj;
@ -1000,6 +1000,8 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
#endif // NECKO
if (NS_FAILED(rv))
return nsnull;
nsIWebShellWindow *aWindow = nsnull; // we will return the window AddRefed
rv = appShellService->CreateTopLevelWindow(
nsnull,
urlObj, // nsIURL* of chrome

Просмотреть файл

@ -163,18 +163,17 @@ nsDownloadProgressDialog::Show() {
if ( NS_SUCCEEDED(rv) ) {
// Create "save to disk" nsIXULCallbacks...
nsIWebShellWindow *newWindow;
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = appShell->CreateTopLevelWindow( nsnull,
url,
PR_TRUE,
newWindow,
*getter_AddRefs(newWindow),
nsnull,
this,
0,
0 );
if ( NS_SUCCEEDED( rv ) ) {
mWindow = newWindow;
NS_RELEASE( newWindow );
} else {
DEBUG_PRINTF( PR_STDOUT, "Error creating download progress dialog, rv=0x%X\n", (int)rv );
}

Просмотреть файл

@ -236,12 +236,11 @@ nsInstallProgressDialog::Open()
if ( NS_SUCCEEDED(rv) )
{
nsIWebShellWindow *newWindow;
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = appShell->CreateTopLevelWindow( nsnull,
url,
PR_TRUE,
newWindow,
*getter_AddRefs(newWindow),
nsnull,
this, // callbacks??
0,
@ -249,8 +248,7 @@ nsInstallProgressDialog::Open()
if ( NS_SUCCEEDED( rv ) )
{
mWindow = newWindow;
NS_RELEASE( newWindow );
mWindow = newWindow; // ownership?
if (mWindow != nsnull)
mWindow->Show(PR_TRUE);