adium 5029:5065b1865e99: Prevent via an @catch/@try/@finally ban...

commits at adium.im commits at adium.im
Wed Sep 5 23:34:22 UTC 2012


details:	http://hg.adium.im/adium/rev/5065b1865e99
revision:	5029:5065b1865e99
branch:		(none)
author:		Evan Schoenberg
date:		Wed Sep 05 18:25:04 2012 -0500

Prevent via an @catch/@try/@finally bandaid #16121. Fixes #16121

diffs (43 lines):

diff -r a5b24a9d8bb5 -r 5065b1865e99 Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m	Thu Sep 06 00:29:35 2012 +0200
+++ b/Source/AILogViewerWindowController.m	Wed Sep 05 18:25:04 2012 -0500
@@ -503,7 +503,7 @@
 	}
 }
 
--(void)rebuildIndices
+- (void)rebuildIndices
 {
     //Rebuild the 'global' log indexes
     [logFromGroupDict release]; logFromGroupDict = [[NSMutableDictionary alloc] init];
@@ -1928,16 +1928,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