change window ownership model to match Mozilla's (self-referential). bug 76522 r=adamlock,hyatt

This commit is contained in:
danm%netscape.com 2001-05-21 22:49:18 +00:00
parent 8e05fc6f8b
commit faa7681f86
2 changed files with 10 additions and 4 deletions

View File

@ -193,8 +193,9 @@ NS_IMETHODIMP WebBrowserChrome::CreateBrowserWindow(PRUint32 aChromeFlags,
nsIWebBrowserChrome *parent = aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT ? this : 0;
nsIWebBrowserChrome *newChrome = nsnull;
rv = AppCallbacks::CreateBrowserWindow(aChromeFlags, parent, &newChrome);
nsCOMPtr<nsIWebBrowserChrome> newChrome;
rv = AppCallbacks::CreateBrowserWindow(aChromeFlags, parent,
getter_AddRefs(newChrome));
if (NS_SUCCEEDED(rv))
{
newChrome->GetWebBrowser(_retval);

View File

@ -280,9 +280,9 @@ nsresult OpenWebPage(const char *url)
// with an extra reference so that it can released correctly during
// destruction (via Win32UI::Destroy)
nsIWebBrowserChrome *chrome = nsnull;
nsCOMPtr<nsIWebBrowserChrome> chrome;
rv = AppCallbacks::CreateBrowserWindow(nsIWebBrowserChrome::CHROME_ALL,
nsnull, &chrome);
nsnull, getter_AddRefs(chrome));
if (NS_SUCCEEDED(rv))
{
WebBrowserChromeUI::ShowWindow(chrome, PR_TRUE);
@ -1275,7 +1275,12 @@ nsresult AppCallbacks::CreateBrowserWindow(PRUint32 aChromeFlags,
if (!chrome)
return NS_ERROR_FAILURE;
// the interface to return and one addref, which we assume will be
// immediately released
CallQueryInterface(NS_STATIC_CAST(nsIWebBrowserChrome*, chrome), aNewWindow);
// now an extra addref; the window owns itself (to be released by
// WebBrowserChromeUI::Destroy)
NS_ADDREF(*aNewWindow);
chrome->SetChromeFlags(aChromeFlags);
chrome->SetParent(aParent);