adium 5037:45a222d15932: Prevent via an @catch/@try/@finally ban...

commits at adium.im commits at adium.im
Thu Sep 6 19:18:29 UTC 2012


details:	http://hg.adium.im/adium/rev/45a222d15932
revision:	5037:45a222d15932
branch:		adium-1.5.4
author:		Evan Schoenberg
date:		Wed Sep 05 18:25:04 2012 -0500

Prevent via an @catch/@try/@finally bandaid #16121. Fixes #16121
Subject: adium 5038:9b51ee404bc6: Added -[AIAdium earliestLaunchedAdiumVersion] which uses some implementation details of other classes to retroactively guess the earliest launched version and tracks it moving forward

details:	http://hg.adium.im/adium/rev/9b51ee404bc6
revision:	5038:9b51ee404bc6
branch:		adium-1.5.4
author:		Evan Schoenberg
date:		Wed Sep 05 23:18:36 2012 -0500

Added -[AIAdium earliestLaunchedAdiumVersion] which uses some implementation details of other classes to retroactively guess the earliest launched version and tracks it moving forward
Subject: adium 5039:68bb3f77b1d0: Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.

details:	http://hg.adium.im/adium/rev/68bb3f77b1d0
revision:	5039:68bb3f77b1d0
branch:		adium-1.5.4
author:		Evan Schoenberg
date:		Wed Sep 05 23:36:01 2012 -0500

Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.

diffs (207 lines):

diff -r a2d01504eb3b -r 68bb3f77b1d0 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Thu Sep 06 21:01:42 2012 +0200
+++ b/Adium.xcodeproj/project.pbxproj	Wed Sep 05 23:36:01 2012 -0500
@@ -663,6 +663,8 @@
 		34D0FDD20956186200DCB678 /* ESPersonalPreferencesPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D0FDD00956186200DCB678 /* ESPersonalPreferencesPlugin.m */; };
 		34D0FDD80956187700DCB678 /* ESPersonalPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D0FDD60956187700DCB678 /* ESPersonalPreferences.m */; };
 		34D0FF8509569FE500DCB678 /* PersonalPreferencesDefaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 34D0FF8409569FE500DCB678 /* PersonalPreferencesDefaults.plist */; };
+		34D7F1EA15F85DD300F32F9B /* ChatCyclingDefaults-Old.plist in Resources */ = {isa = PBXBuildFile; fileRef = 34D7F1E815F85DD300F32F9B /* ChatCyclingDefaults-Old.plist */; };
+		34D7F1EB15F85DD300F32F9B /* ChatCyclingDefaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 34D7F1E915F85DD300F32F9B /* ChatCyclingDefaults.plist */; };
 		34D8153A13B663650022C8C4 /* AIFacebookXMPPAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = 34D8153013B663650022C8C4 /* AIFacebookXMPPAccount.h */; };
 		34D8153B13B663650022C8C4 /* AIFacebookXMPPAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8153113B663650022C8C4 /* AIFacebookXMPPAccount.m */; };
 		34D8153D13B663650022C8C4 /* AIFacebookXMPPAccountViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34D8153313B663650022C8C4 /* AIFacebookXMPPAccountViewController.h */; };
@@ -3539,6 +3541,8 @@
 		34D369ED08E7544D00E15E40 /* AIColorPickerSliders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIColorPickerSliders.h; path = "Frameworks/Adium Framework/Source/AIColorPickerSliders.h"; sourceTree = "<group>"; };
 		34D369EE08E7544D00E15E40 /* AIColorPickerSliders.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIColorPickerSliders.m; path = "Frameworks/Adium Framework/Source/AIColorPickerSliders.m"; sourceTree = "<group>"; };
 		34D43504051ADC10003B2F21 /* DualWindowDefaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = DualWindowDefaults.plist; path = "Plugins/Dual Window Interface/DualWindowDefaults.plist"; sourceTree = "<group>"; };
+		34D7F1E815F85DD300F32F9B /* ChatCyclingDefaults-Old.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "ChatCyclingDefaults-Old.plist"; path = "Resources/ChatCyclingDefaults-Old.plist"; sourceTree = "<group>"; };
+		34D7F1E915F85DD300F32F9B /* ChatCyclingDefaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = ChatCyclingDefaults.plist; path = Resources/ChatCyclingDefaults.plist; sourceTree = "<group>"; };
 		34D8153013B663650022C8C4 /* AIFacebookXMPPAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIFacebookXMPPAccount.h; path = "Plugins/Purple Service/AIFacebookXMPPAccount.h"; sourceTree = "<group>"; };
 		34D8153113B663650022C8C4 /* AIFacebookXMPPAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIFacebookXMPPAccount.m; path = "Plugins/Purple Service/AIFacebookXMPPAccount.m"; sourceTree = "<group>"; };
 		34D8153313B663650022C8C4 /* AIFacebookXMPPAccountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIFacebookXMPPAccountViewController.h; path = "Plugins/Purple Service/AIFacebookXMPPAccountViewController.h"; sourceTree = "<group>"; };
@@ -6776,6 +6780,8 @@
 			children = (
 				34BFE20007E8E11500AD984D /* AIChatCyclingPlugin.m */,
 				34BFE20107E8E11500AD984D /* AIChatCyclingPlugin.h */,
+				34D7F1E815F85DD300F32F9B /* ChatCyclingDefaults-Old.plist */,
+				34D7F1E915F85DD300F32F9B /* ChatCyclingDefaults.plist */,
 			);
 			name = "Chat Cycling";
 			sourceTree = "<group>";
diff -r a2d01504eb3b -r 68bb3f77b1d0 Frameworks/Adium Framework/Source/AIAdiumProtocol.h
--- a/Frameworks/Adium Framework/Source/AIAdiumProtocol.h	Thu Sep 06 21:01:42 2012 +0200
+++ b/Frameworks/Adium Framework/Source/AIAdiumProtocol.h	Wed Sep 05 23:36:01 2012 -0500
@@ -61,6 +61,7 @@
 @property (readonly, nonatomic) NSString *cachesPath;
 
 - (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
+- (NSString *)earliestLaunchedAdiumVersion;
 
 @property (readonly, nonatomic) BOOL isQuitting;
 
diff -r a2d01504eb3b -r 68bb3f77b1d0 Resources/ChatCyclingDefaults-Old.plist
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/ChatCyclingDefaults-Old.plist	Wed Sep 05 23:36:01 2012 -0500
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Tab Switching Keys</key>
+	<integer>0</integer>
+</dict>
+</plist>
diff -r a2d01504eb3b -r 68bb3f77b1d0 Resources/ChatCyclingDefaults.plist
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/ChatCyclingDefaults.plist	Wed Sep 05 23:36:01 2012 -0500
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Tab Switching Keys</key>
+	<integer>5</integer>
+</dict>
+</plist>
diff -r a2d01504eb3b -r 68bb3f77b1d0 Source/AIAdium.m
--- a/Source/AIAdium.m	Thu Sep 06 21:01:42 2012 +0200
+++ b/Source/AIAdium.m	Wed Sep 05 23:36:01 2012 -0500
@@ -72,6 +72,8 @@
 
 #define ALWAYS_RUN_SETUP_WIZARD FALSE
 
+#define AIEarliestLaunchedAdiumVersionKey @"AIEarliestLaunchedAdiumVersion"
+
 static NSString	*prefsCategory;
 
 @interface AIAdium ()
@@ -137,6 +139,8 @@
 												   andSelector:@selector(handleURLEvent:withReplyEvent:)
 												 forEventClass:kInternetEventClass
 													andEventID:kAEGetURL];
+	
+	[self noteEarliestLaunchedAdiumVersion];
 }
 
 - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
@@ -1002,6 +1006,43 @@
 	return [NSApplication sharedApplication];
 }
 
+- (NSString *)earliestLaunchedAdiumVersion
+{
+	return [[NSUserDefaults standardUserDefaults] stringForKey:AIEarliestLaunchedAdiumVersionKey];
+}
+
+- (void)noteEarliestLaunchedAdiumVersion
+{
+	if (![self earliestLaunchedAdiumVersion]) {
+		/* Either Adium has never run before on this machine, or the version which did was < 1.5.4, as that's when we started
+		 * noting the earliest run version
+		 */
+		if ([[NSUserDefaults standardUserDefaults]  boolForKey:@"Adium 1.3.3:Reimported Spotlight Logs"]) {
+			/* This is set by the logging plugin in every version of Adium from 1.3.3 through 1.5.3, so if it's already set,
+			 * Adium 1.3.3 through 1.5.3 have launched previously. Assume 1.5.3 since we can't tell the difference.
+			 */
+			[[NSUserDefaults standardUserDefaults] setObject:@"1.5.3"
+													  forKey:AIEarliestLaunchedAdiumVersionKey];
+			
+		} else if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Adium 1.2.4 deleted blist.xml"]) {
+			/* similar story, so now we're between 1.2.4 and 1.3.2 */
+			[[NSUserDefaults standardUserDefaults] setObject:@"1.3.2"
+													  forKey:AIEarliestLaunchedAdiumVersionKey];
+			
+		} else if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Adium 1.0.3 moved to libpurple"]) {
+			/* similar story, so now we're between 1.0.3 and 1.2.3. Really, you're just now upgrading?! */
+			[[NSUserDefaults standardUserDefaults] setObject:@"1.2.3"
+													  forKey:AIEarliestLaunchedAdiumVersionKey];
+		} else {
+			/* This user has never run Adium, at least not since 1.0.3. Record the current version */
+			[[NSUserDefaults standardUserDefaults] setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]
+													  forKey:AIEarliestLaunchedAdiumVersionKey];
+			
+		}
+		
+	}
+}
+
 #pragma mark Scripting
 - (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key {
 	BOOL handleKey = NO;
diff -r a2d01504eb3b -r 68bb3f77b1d0 Source/AIChatCyclingPlugin.m
--- a/Source/AIChatCyclingPlugin.m	Thu Sep 06 21:01:42 2012 +0200
+++ b/Source/AIChatCyclingPlugin.m	Wed Sep 05 23:36:01 2012 -0500
@@ -19,10 +19,14 @@
 #import <Adium/AIMenuControllerProtocol.h>
 #import "ESGeneralPreferencesPlugin.h"
 #import <AIUtilities/AIMenuAdditions.h>
+#import <AIUtilities/AIDictionaryAdditions.h>
 
 #define PREVIOUS_MESSAGE_MENU_TITLE		AILocalizedString(@"Previous Chat",nil)
 #define NEXT_MESSAGE_MENU_TITLE			AILocalizedString(@"Next Chat",nil)
 
+#define DEFAULT_CHAT_CYCLING_PREFS		@"ChatCyclingDefaults"
+#define OLD_DEFAULT_CHAT_CYCLING_PREFS	@"ChatCyclingDefaults-Old"
+
 /*!
  * @class AIChatCyclingPlugin
  * @brief Component to manage the chat cycling menu items
@@ -50,6 +54,15 @@
 												  action:@selector(nextChat:)
 										   keyEquivalent:@""];
 	[menuController addMenuItem:nextChatMenuItem toLocation:LOC_Window_Commands];
+		
+	/* Adium 1.5.4+ use the new defaults for chat switching, ctrl+tab, to match Safari's default user-visible behavior */
+	NSDictionary *defaults = [NSDictionary dictionaryNamed:(([adium compareVersion:adium.earliestLaunchedAdiumVersion
+																		 toVersion:@"1.5.4"] == NSOrderedAscending) ?
+															OLD_DEFAULT_CHAT_CYCLING_PREFS :
+															DEFAULT_CHAT_CYCLING_PREFS)
+												  forClass:[self class]];
+	[adium.preferenceController registerDefaults:defaults
+											forGroup:PREF_GROUP_CHAT_CYCLING];
 
 	//Prefs
 	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_CHAT_CYCLING];
diff -r a2d01504eb3b -r 68bb3f77b1d0 Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m	Thu Sep 06 21:01:42 2012 +0200
+++ b/Source/AILogViewerWindowController.m	Wed Sep 05 23:36:01 2012 -0500
@@ -497,7 +497,7 @@
 	}
 }
 
--(void)rebuildIndices
+- (void)rebuildIndices
 {
     //Rebuild the 'global' log indexes
     [logFromGroupDict release]; logFromGroupDict = [[NSMutableDictionary alloc] init];
@@ -1927,16 +1927,27 @@
 - (void)tableViewSelectionDidChangeDelayed
 {
     if (!ignoreSelectionChange) {
-		NSArray		*selectedLogs;
+		NSArray		*selectedLogs = nil;
 		
 		//Update the displayed log
 		automaticSearch = NO;
 		
 		[resultsLock lock];
-		selectedLogs = [tableView_results selectedItemsFromArray:currentSearchResults];
+		@try {
+			/* If currentSearchResults is out of sync with the data of tableView_results, this could throw an exception.
+			 * Catching it is far more straightforward than preventing that possibility without breaking our re-selection of
+			 * selected search results as the table view reloads when new results come in.
+			 */
+			selectedLogs = [tableView_results selectedItemsFromArray:currentSearchResults];
+		} @catch (NSException *e) {
+			
+		} @finally {
+			
+		}
 		[resultsLock unlock];
 		
-		[self displayLogs:selectedLogs];
+		if (selectedLogs)
+			[self displayLogs:selectedLogs];
     }
 }
 




More information about the commits mailing list