From 905a44014caa805f2b2621bedef3a76da259c8b1 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 28 Mar 2009 00:31:08 +0000 Subject: Improve interaction with connection favorites to prevent issues saving favorite changes: - Favorites are no longer resaved on document window close - instead they're saved on connect. Prevents the oldest window open from saving its favorites when closed, overwriting any changes since. - Explicitly synchs changes to disk to ensure prefs window/connection sheets see each other's changes faster. --- Source/MainController.m | 5 +++++ Source/TableDocument.m | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/MainController.m b/Source/MainController.m index c5e2eeb0..8c76014a 100644 --- a/Source/MainController.m +++ b/Source/MainController.m @@ -33,6 +33,10 @@ opens the preferences window */ - (IBAction)openPreferences:(id)sender { + + // Synchronize the prefs to disk to pick up any changes made to favourites in connection sheets + [prefs synchronize]; + //get favorites if they exist [favorites release]; if ( [prefs objectForKey:@"favorites"] != nil ) { @@ -627,6 +631,7 @@ checks for updates and opens download page in default browser [prefs setObject:[encodingPopUpButton titleOfSelectedItem] forKey:@"encoding"]; [prefs setObject:favorites forKey:@"favorites"]; + [prefs synchronize]; } return YES; } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 738af532..012b30dc 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -139,6 +139,10 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa - (IBAction)connect:(id)sender { int code; + + // Save the favourites - commits any unsaved changes ie favourite renames + [prefs setObject:[self favorites] forKey:@"favorites"]; + [prefs synchronize]; [connectProgressBar startAnimation:self]; [connectProgressStatusText setHidden:NO]; @@ -1650,10 +1654,6 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn - (IBAction)terminate:(id)sender { [[NSApp orderedDocuments] makeObjectsPerformSelector:@selector(cancelConnectSheet:) withObject:nil]; - - // Save the favourites - commits any unsaved changes ie favourite renames - [prefs setObject:[self favorites] forKey:@"favorites"]; - [NSApp terminate:sender]; } -- cgit v1.2.3