Camino only - Bug 373949: Fix crash detection when session saving is disabled. r=murph sr=josh
This commit is contained in:
Родитель
da51b74546
Коммит
e5e51243af
|
@ -124,7 +124,6 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
- (void)loadApplicationPage:(NSString*)pageURL;
|
||||
- (NSArray*)browserWindows;
|
||||
+ (NSURL*)decodeLocalFileURL:(NSURL*)url;
|
||||
- (BOOL)previousSessionTerminatedNormally;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -266,12 +265,19 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
NSString* charsetPath = [NSBundle pathForResource:@"Charset" ofType:@"dict" inDirectory:[[NSBundle mainBundle] bundlePath]];
|
||||
mCharsets = [[NSDictionary dictionaryWithContentsOfFile:charsetPath] retain];
|
||||
|
||||
// Check whether Camino shut down normally last time...
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:@"YES" forKey:kPreviousSessionTerminatedNormallyKey]];
|
||||
BOOL previousSessionTerminatedNormally = [[NSUserDefaults standardUserDefaults] boolForKey:kPreviousSessionTerminatedNormallyKey];
|
||||
// ... then reset the state for the next time around.
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:kPreviousSessionTerminatedNormallyKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
// Determine if the previous session's window state should be restored.
|
||||
// Obey the camino.remember_window_state preference unless Camino crashed
|
||||
// last time, in which case the user is asked what to do.
|
||||
BOOL shouldRestoreWindowState = NO;
|
||||
if ([[SessionManager sharedInstance] hasSavedState]) {
|
||||
if ([self previousSessionTerminatedNormally]) {
|
||||
if (previousSessionTerminatedNormally) {
|
||||
shouldRestoreWindowState = [prefManager getBooleanPref:"camino.remember_window_state" withSuccess:NULL];
|
||||
}
|
||||
else if ([prefManager getBooleanPref:"browser.sessionstore.resume_from_crash" withSuccess:NULL]) {
|
||||
|
@ -503,37 +509,6 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
[self updateDockMenuBookmarkFolder];
|
||||
}
|
||||
|
||||
//
|
||||
// -previousSessionTerminatedNormally
|
||||
//
|
||||
// Checks a saved default indicating whether the last session ended normally.
|
||||
// The first invocation of this method will check the default on disk and then
|
||||
// immediately reset it to "NO". This default is set to "YES" upon normal
|
||||
// termination in -applicationWillTerminate:.
|
||||
//
|
||||
- (BOOL)previousSessionTerminatedNormally
|
||||
{
|
||||
static BOOL previousSessionTerminatedNormally = NO; // original value from defaults.
|
||||
static BOOL checked = NO;
|
||||
|
||||
if (!checked) {
|
||||
// Assume the application terminated normally if no key is present to otherwise
|
||||
// indicate the termination status. Prevents cases where preferences from older
|
||||
// versions of Camino would falsely indicate a crash.
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:@"YES" forKey:kPreviousSessionTerminatedNormallyKey]];
|
||||
|
||||
previousSessionTerminatedNormally = [[NSUserDefaults standardUserDefaults] boolForKey:kPreviousSessionTerminatedNormallyKey];
|
||||
|
||||
// Reset the termination status default and write it to disk now.
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:kPreviousSessionTerminatedNormallyKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
checked = YES;
|
||||
}
|
||||
|
||||
return previousSessionTerminatedNormally;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Window Accesssors
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче