Skip to content

Commit

Permalink
Re-do prompt-on-close migration. Users who had manually set Always Pr…
Browse files Browse the repository at this point in the history
…mopt will lose that change.
  • Loading branch information
gnachman committed Sep 4, 2011
1 parent ed973c0 commit bf89ff4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions BookmarkModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,26 @@ - (void)addBookmark:(Bookmark*)bookmark
+ (void)migratePromptOnCloseInMutableBookmark:(NSMutableDictionary *)dict
{
// Migrate global "prompt on close" to per-profile prompt enum
if ([dict objectForKey:KEY_PROMPT_CLOSE_DEPRECATED]) {
// The 8/28 build incorrectly ignored the OnlyWhenMoreTabs setting
// when migrating PromptOnClose to KEY_PRMOPT_CLOSE. Its preference
// key has been changed to KEY_PROMPT_CLOSE_DEPRECATED and a new
// pref key with the same intended usage has been added on 9/4 but
// with a different name. If the setting is PROMPT_ALWAYS, then it may
// have been migrated incorrectly. There are three ways to get here:
// 1. PromptOnClose && OnlyWhenMoreTabs was migrated wrong.
// 2. PromptOnClose && !OnlyWhenMoreTabs was migrated right.
// 3. Post migration, the user set it to PROMPT_ALWAYS
//
// For case 1, redoing the migration produces the correct result.
// For case 2, redoing the migration has no effect.
// For case 3, the user's pref is overwritten. This should be rare.
int value = [[dict objectForKey:KEY_PROMPT_CLOSE_DEPRECATED] intValue];
if (value != PROMPT_ALWAYS) {
[dict setObject:[NSNumber numberWithInt:value]
forKey:KEY_PROMPT_CLOSE];
}
}
if (![dict objectForKey:KEY_PROMPT_CLOSE]) {
BOOL promptOnClose = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PromptOnClose"] boolValue];
NSNumber *onlyWhenNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"OnlyWhenMoreTabs"];
Expand Down
3 changes: 2 additions & 1 deletion ITAddressBookMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
#define KEY_LOGDIR @"Log Directory"
#define KEY_SEND_CODE_WHEN_IDLE @"Send Code When Idle"
#define KEY_IDLE_CODE @"Idle Code"
#define KEY_PROMPT_CLOSE @"Prompt Before Closing"
#define KEY_PROMPT_CLOSE_DEPRECATED @"Prompt Before Closing" // Deprecated due to bad migration in 8/28 build
#define KEY_PROMPT_CLOSE @"Prompt Before Closing 2"
#define KEY_JOBS @"Jobs to Ignore"

// Keyboard
Expand Down

0 comments on commit bf89ff4

Please sign in to comment.