Fixed regression in reopening documents introduced in previous commit

This commit is contained in:
michael starke
2013-11-23 04:08:20 +01:00
parent 73f21c06e0
commit d186a2f318
2 changed files with 10 additions and 14 deletions

View File

@@ -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;

View File

@@ -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);
}
}