adium 3688:7e0b0cdfc8ff: Perform the resize on the main thread t...

commits at adium.im commits at adium.im
Fri Feb 25 23:06:49 UTC 2011


details:	http://hg.adium.im/adium/rev/7e0b0cdfc8ff
revision:	3688:7e0b0cdfc8ff
author:		Frank Dowsett <wixardy at adium.im>
date:		Fri Feb 25 17:21:58 2011 -0500

Perform the resize on the main thread to avoid crashing fixes #14998

diffs (90 lines):

diff -r 8ae2aea0f3e3 -r 7e0b0cdfc8ff Plugins/Dock Icon Badging/AIDockNameOverlay.m
--- a/Plugins/Dock Icon Badging/AIDockNameOverlay.m	Thu Feb 24 13:54:11 2011 -0600
+++ b/Plugins/Dock Icon Badging/AIDockNameOverlay.m	Fri Feb 25 17:21:58 2011 -0500
@@ -337,6 +337,7 @@
 	[image unlockFocus];
 	
 	[adium.dockController setOverlay:image];
+	[image release];
 }
 
 @end
diff -r 8ae2aea0f3e3 -r 7e0b0cdfc8ff Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m	Thu Feb 24 13:54:11 2011 -0600
+++ b/Source/AILogViewerWindowController.m	Fri Feb 25 17:21:58 2011 -0500
@@ -118,6 +118,8 @@
 - (void)openChatOnDoubleAction:(id)sender;
 - (void)deleteLogsAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
 NSInteger compareRectLocation(id obj1, id obj2, void *context);
+
+- (void)setNavBarHidden:(NSNumber *)hide;
 @end
 
 @implementation AILogViewerWindowController
@@ -454,10 +456,9 @@
 	}
 	
 	//hide find navigation bar
-	[view_FindNavigator setHidden:YES];
-	NSSize contentSize = [textView_content enclosingScrollView].frame.size;
-	contentSize.height += view_FindNavigator.frame.size.height;
-	[[textView_content enclosingScrollView] setFrameSize:contentSize];
+	[self performSelectorOnMainThread:@selector(setNavBarHidden:)
+						   withObject:[NSNumber numberWithBool:YES]
+						waitUntilDone:YES];
 
 	//Set a gradient for the background
 	[view_FindNavigator setStartingColor:[NSColor colorWithCalibratedWhite:0.92 alpha:1.0]];
@@ -928,21 +929,13 @@
 							waitUntilDone:YES];
 
 		if (currentMatch > 0) {
-			//show find navigation bar
-			if ([view_FindNavigator isHidden]) {
-				[view_FindNavigator setHidden:NO];
-				NSSize contentSize = [textView_content enclosingScrollView].frame.size;
-				contentSize.height -= view_FindNavigator.frame.size.height;
-				[[textView_content enclosingScrollView] setFrameSize:contentSize];
-			}
+			[self performSelectorOnMainThread:@selector(setNavBarHidden:)
+								   withObject:[NSNumber numberWithBool:NO]
+								waitUntilDone:YES];
 		} else {
-			//hide find navigation bar
-			if (![view_FindNavigator isHidden]) {
-				[view_FindNavigator setHidden:YES];
-				NSSize contentSize = [textView_content enclosingScrollView].frame.size;
-				contentSize.height += view_FindNavigator.frame.size.height;
-				[[textView_content enclosingScrollView] setFrameSize:contentSize];
-			}
+			[self performSelectorOnMainThread:@selector(setNavBarHidden:)
+								   withObject:[NSNumber numberWithBool:YES]
+								waitUntilDone:YES];
 		}
 	}
 
@@ -1069,6 +1062,24 @@
     }
 }
 
+/* Show or hide the bar that contains the next/previous buttons for navigating search results
+ * This needs to be run on the main thread hence it's not a BOOL
+ */
+- (void)setNavBarHidden:(NSNumber *)hide
+{
+	NSSize contentSize = [textView_content enclosingScrollView].frame.size;
+
+	//show
+	if (![hide boolValue] && [view_FindNavigator isHidden])
+		contentSize.height -= view_FindNavigator.frame.size.height;
+	//hide
+	else if ([hide boolValue] && ![view_FindNavigator isHidden])
+		contentSize.height += view_FindNavigator.frame.size.height;
+
+	[[textView_content enclosingScrollView] setFrameSize:contentSize];
+	[view_FindNavigator setHidden:[hide boolValue]];
+}
+
 - (IBAction)selectNextPreviousOccurrence:(id)sender;
 {
 	NSInteger selectedSegment = [sender selectedSegment];




More information about the commits mailing list