diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index 74a555e4..b4d10e76 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -13,6 +13,7 @@ @property (strong) IBOutlet NSWindow *passwordCreatorWindow; @property (strong) IBOutlet NSWindow *welcomeWindow; +- (IBAction)showPreferences:(id)sender; - (IBAction)showPasswordCreator:(id)sender; - (IBAction)createNewDatabase:(id)sender; - (IBAction)openDatabase:(id)sender; diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 0f38a81c..2aeca038 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -24,15 +24,13 @@ MPServerDaemon *serverDaemon; MPLockDaemon *lockDaemon; MPAutotypeDaemon *autotypeDaemon; - BOOL _restoredWindows; - BOOL _shouldOpenFile; + BOOL _restoredWindows; // YES if windows where restored at launch + BOOL _shouldOpenFile; // YES if app was started to open a } @property (strong, nonatomic) MPSettingsWindowController *settingsController; @property (strong, nonatomic) MPPasswordCreatorViewController *passwordCreatorController; -- (IBAction)showPreferences:(id)sender; - @end @implementation MPAppDelegate @@ -68,16 +66,14 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification { - BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch]; _restoredWindows = NO; _shouldOpenFile = NO; - if(reopen) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_applicationDidFinishRestoringWindows:) - name:NSApplicationDidFinishRestoringWindowsNotification - object:nil]; - - } + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(_applicationDidFinishRestoringWindows:) + name:NSApplicationDidFinishRestoringWindowsNotification + object:nil]; + + } - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { @@ -93,7 +89,7 @@ autotypeDaemon = [[MPAutotypeDaemon alloc] init]; BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch]; - BOOL showWelcomeScreen = !_shouldOpenFile; + BOOL showWelcomeScreen = !_restoredWindows && !_shouldOpenFile; if(reopen && !_restoredWindows && !_shouldOpenFile) { showWelcomeScreen = ![self _reopenLastDocument]; } @@ -162,7 +158,6 @@ if(!_welcomeWindow) { NSArray *topLevelObject; [[NSBundle mainBundle] loadNibNamed:@"WelcomeWindow" owner:self topLevelObjects:&topLevelObject]; - //CFRelease((__bridge CFTypeRef)_welcomeWindow); } }