Keep XPCOM from being shut down while this window is open (bug 160241)

This commit is contained in:
pinkerton%netscape.com 2002-08-01 18:00:50 +00:00
parent 9796b09a1c
commit 3f53046bea
4 changed files with 48 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCocoaBrowserService.h"
// #import "Defines.h"
@ -70,6 +71,7 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
loadedPanes = nil;
panes = nil;
paneInfo = nil;
[super dealloc];
}
@ -107,6 +109,13 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (IBAction) showPreferences:(id) sender
{
if ( ![window isVisible] ) {
// on being shown, register as a window that cares about XPCOM being active until we're done
// with it in |windowDidClose()|. Need to ensure this is exactly balanced with |BrowserClosed()|
// calls as it increments a refcount. As a result, we can only call it when we're making
// the window visible. Too bad cocoa doesn't give us any notifications of this.
nsCocoaBrowserService::InitEmbedding();
}
[self showAll:nil];
[window makeKeyAndOrderFront:nil];
}
@ -225,6 +234,9 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
if ( prefService )
prefService->SavePrefFile(nsnull); // nsnull means write to prefs.js
[[NSUserDefaults standardUserDefaults] synchronize];
// tell gecko that this window no longer needs it around.
nsCocoaBrowserService::BrowserClosed();
}
- (NSToolbarItem *) toolbar:(NSToolbar *) toolbar

View File

@ -7,6 +7,7 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCocoaBrowserService.h"
// #import "Defines.h"
@ -70,6 +71,7 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
loadedPanes = nil;
panes = nil;
paneInfo = nil;
[super dealloc];
}
@ -107,6 +109,13 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (IBAction) showPreferences:(id) sender
{
if ( ![window isVisible] ) {
// on being shown, register as a window that cares about XPCOM being active until we're done
// with it in |windowDidClose()|. Need to ensure this is exactly balanced with |BrowserClosed()|
// calls as it increments a refcount. As a result, we can only call it when we're making
// the window visible. Too bad cocoa doesn't give us any notifications of this.
nsCocoaBrowserService::InitEmbedding();
}
[self showAll:nil];
[window makeKeyAndOrderFront:nil];
}
@ -225,6 +234,9 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
if ( prefService )
prefService->SavePrefFile(nsnull); // nsnull means write to prefs.js
[[NSUserDefaults standardUserDefaults] synchronize];
// tell gecko that this window no longer needs it around.
nsCocoaBrowserService::BrowserClosed();
}
- (NSToolbarItem *) toolbar:(NSToolbar *) toolbar

View File

@ -7,6 +7,7 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCocoaBrowserService.h"
// #import "Defines.h"
@ -70,6 +71,7 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
loadedPanes = nil;
panes = nil;
paneInfo = nil;
[super dealloc];
}
@ -107,6 +109,13 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (IBAction) showPreferences:(id) sender
{
if ( ![window isVisible] ) {
// on being shown, register as a window that cares about XPCOM being active until we're done
// with it in |windowDidClose()|. Need to ensure this is exactly balanced with |BrowserClosed()|
// calls as it increments a refcount. As a result, we can only call it when we're making
// the window visible. Too bad cocoa doesn't give us any notifications of this.
nsCocoaBrowserService::InitEmbedding();
}
[self showAll:nil];
[window makeKeyAndOrderFront:nil];
}
@ -225,6 +234,9 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
if ( prefService )
prefService->SavePrefFile(nsnull); // nsnull means write to prefs.js
[[NSUserDefaults standardUserDefaults] synchronize];
// tell gecko that this window no longer needs it around.
nsCocoaBrowserService::BrowserClosed();
}
- (NSToolbarItem *) toolbar:(NSToolbar *) toolbar

View File

@ -7,6 +7,7 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCocoaBrowserService.h"
// #import "Defines.h"
@ -70,6 +71,7 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
loadedPanes = nil;
panes = nil;
paneInfo = nil;
[super dealloc];
}
@ -107,6 +109,13 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (IBAction) showPreferences:(id) sender
{
if ( ![window isVisible] ) {
// on being shown, register as a window that cares about XPCOM being active until we're done
// with it in |windowDidClose()|. Need to ensure this is exactly balanced with |BrowserClosed()|
// calls as it increments a refcount. As a result, we can only call it when we're making
// the window visible. Too bad cocoa doesn't give us any notifications of this.
nsCocoaBrowserService::InitEmbedding();
}
[self showAll:nil];
[window makeKeyAndOrderFront:nil];
}
@ -225,6 +234,9 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
if ( prefService )
prefService->SavePrefFile(nsnull); // nsnull means write to prefs.js
[[NSUserDefaults standardUserDefaults] synchronize];
// tell gecko that this window no longer needs it around.
nsCocoaBrowserService::BrowserClosed();
}
- (NSToolbarItem *) toolbar:(NSToolbar *) toolbar