adium 4324:6e513a922a44: Correct strange behavior in the message...

commits at adium.im commits at adium.im
Tue Nov 29 00:20:26 UTC 2011


details:	http://hg.adium.im/adium/rev/6e513a922a44
revision:	4324:6e513a922a44
branch:		(none)
author:		Stephen Holt <sholt at adium.im>
date:		Mon Nov 28 16:20:28 2011 -0800

Correct strange behavior in the messages pref pane. Fixes #15670

diffs (234 lines):

diff -r 2fc2a962fc5c -r 6e513a922a44 ChangeLogs/Changes Between Betas.txt
--- a/ChangeLogs/Changes Between Betas.txt	Mon Nov 28 14:15:13 2011 +0100
+++ b/ChangeLogs/Changes Between Betas.txt	Mon Nov 28 16:20:28 2011 -0800
@@ -1,5 +1,6 @@
 Adium 1.5b6
  * Fixed automatic updating between betas failing with the error "Can't make a temporary directory for the update download". (#15666)
+ * Correct strange behavior in the messages pref pane. (#15670)
 
 Adium 1.5b5
  * Fixed crash when loading Skype plugin. (#15590)
diff -r 2fc2a962fc5c -r 6e513a922a44 Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Mon Nov 28 14:15:13 2011 +0100
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Mon Nov 28 16:20:28 2011 -0800
@@ -352,116 +352,118 @@
  */
 - (void)_updateWebViewForCurrentPreferences
 {
-	dispatch_async(dispatch_get_main_queue(), ^{
-		//Cleanup first
-		[messageStyle autorelease]; messageStyle = nil;
-		[activeStyle release]; activeStyle = nil;
-		
-		//Load the message style
-		messageStyle = [[plugin currentMessageStyleForChat:chat] retain];
-		activeStyle = [[[messageStyle bundle] bundleIdentifier] retain];
-		preferenceGroup = [[plugin preferenceGroupForChat:chat] retain];
-		
-		[webView setPreferencesIdentifier:[NSString stringWithFormat:@"%@-%@",
-										   activeStyle, preferenceGroup]];
-		
-		//Get the prefered variant (or the default if a prefered is not available)
-		NSString *activeVariant;
-		activeVariant = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Variant" forStyle:activeStyle]
-															   group:preferenceGroup];
-		if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant])
-			activeVariant = [messageStyle defaultVariant];
-		if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant]) {
-			/* If the message style doesn't specify a default variant, choose the first one.
-			 * Note: Old styles (styleVersion < 3) will always report a variant for defaultVariant.
-			 */
-			NSArray *availableVariants = [messageStyle availableVariants];
-			if ([availableVariants count]) {
-				activeVariant = [availableVariants objectAtIndex:0];
+	//Cleanup first
+	[messageStyle autorelease]; messageStyle = nil;
+	[activeStyle release]; activeStyle = nil;
+	
+	//Load the message style
+	messageStyle = [[plugin currentMessageStyleForChat:chat] retain];
+	activeStyle = [[[messageStyle bundle] bundleIdentifier] retain];
+	preferenceGroup = [[plugin preferenceGroupForChat:chat] retain];
+	
+	[webView setPreferencesIdentifier:[NSString stringWithFormat:@"%@-%@",
+									   activeStyle, preferenceGroup]];
+	
+	//Get the prefered variant (or the default if a prefered is not available)
+	NSString *activeVariant;
+	activeVariant = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Variant" forStyle:activeStyle]
+														   group:preferenceGroup];
+	if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant])
+		activeVariant = [messageStyle defaultVariant];
+	if (!activeVariant || ![[messageStyle availableVariants] containsObject:activeVariant]) {
+		/* If the message style doesn't specify a default variant, choose the first one.
+		 * Note: Old styles (styleVersion < 3) will always report a variant for defaultVariant.
+		 */
+		NSArray *availableVariants = [messageStyle availableVariants];
+		if ([availableVariants count]) {
+			activeVariant = [availableVariants objectAtIndex:0];
+		}
+	}
+	messageStyle.activeVariant = activeVariant;
+	
+	NSDictionary *prefDict = [adium.preferenceController preferencesForGroup:preferenceGroup];
+	
+	//Update message style behavior: XXX move this somewhere not per-chat
+	[messageStyle setShowUserIcons:[[prefDict objectForKey:KEY_WEBKIT_SHOW_USER_ICONS] boolValue]];
+	[messageStyle setShowHeader:[[prefDict objectForKey:KEY_WEBKIT_SHOW_HEADER] boolValue]];
+	[messageStyle setUseCustomNameFormat:[[prefDict objectForKey:KEY_WEBKIT_USE_NAME_FORMAT] boolValue]];
+	[messageStyle setNameFormat:[[prefDict objectForKey:KEY_WEBKIT_NAME_FORMAT] intValue]];
+	[messageStyle setDateFormat:[prefDict objectForKey:KEY_WEBKIT_TIME_STAMP_FORMAT]];
+	[messageStyle setShowIncomingMessageColors:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_COLORS] boolValue]];
+	[messageStyle setShowIncomingMessageFonts:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_FONTS] boolValue]];
+	
+	//Custom background image
+	//Webkit wants to load these from disk, but we have it stuffed in a plist.  So we'll write it out as an image
+	//into the cache and have webkit fetch from there.
+	NSString	*cachePath = nil;
+	if ([[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"UseCustomBackground" forStyle:activeStyle]
+												group:preferenceGroup] boolValue]) {
+		cachePath = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
+														   group:preferenceGroup];
+		if (!cachePath || ![[NSFileManager defaultManager] fileExistsAtPath:cachePath]) {
+			NSData	*backgroundImage = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Background" forStyle:activeStyle]
+																			 group:PREF_GROUP_WEBKIT_BACKGROUND_IMAGES];
+			
+			if (backgroundImage) {
+				//Generate a unique cache ID for this image
+				NSInteger	uniqueID = [[adium.preferenceController preferenceForKey:@"BackgroundCacheUniqueID"
+																			 group:preferenceGroup] integerValue] + 1;
+				[adium.preferenceController setPreference:[NSNumber numberWithInteger:uniqueID]
+												   forKey:@"BackgroundCacheUniqueID"
+													group:preferenceGroup];
+				
+				//Cache the image under that unique ID
+				//Since we prefix the filename with TEMP, Adium will automatically clean it up on quit
+				cachePath = [self _webKitBackgroundImagePathForUniqueID:uniqueID];
+				[backgroundImage writeToFile:cachePath atomically:YES];
+				
+				//Remember where we cached it
+				[adium.preferenceController setPreference:cachePath
+												   forKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
+													group:preferenceGroup];
+			} else {
+				cachePath = @""; //No custom image found
 			}
 		}
-		messageStyle.activeVariant = activeVariant;
 		
-		NSDictionary *prefDict = [adium.preferenceController preferencesForGroup:preferenceGroup];
-		
-		//Update message style behavior: XXX move this somewhere not per-chat
-		[messageStyle setShowUserIcons:[[prefDict objectForKey:KEY_WEBKIT_SHOW_USER_ICONS] boolValue]];
-		[messageStyle setShowHeader:[[prefDict objectForKey:KEY_WEBKIT_SHOW_HEADER] boolValue]];
-		[messageStyle setUseCustomNameFormat:[[prefDict objectForKey:KEY_WEBKIT_USE_NAME_FORMAT] boolValue]];
-		[messageStyle setNameFormat:[[prefDict objectForKey:KEY_WEBKIT_NAME_FORMAT] intValue]];
-		[messageStyle setDateFormat:[prefDict objectForKey:KEY_WEBKIT_TIME_STAMP_FORMAT]];
-		[messageStyle setShowIncomingMessageColors:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_COLORS] boolValue]];
-		[messageStyle setShowIncomingMessageFonts:[[prefDict objectForKey:KEY_WEBKIT_SHOW_MESSAGE_FONTS] boolValue]];
-		
-		//Custom background image
-		//Webkit wants to load these from disk, but we have it stuffed in a plist.  So we'll write it out as an image
-		//into the cache and have webkit fetch from there.
-		NSString	*cachePath = nil;
-		if ([[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"UseCustomBackground" forStyle:activeStyle]
-													group:preferenceGroup] boolValue]) {
-			cachePath = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
+		[messageStyle setCustomBackgroundColor:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundColor" forStyle:activeStyle]
+																					   group:preferenceGroup] representedColor]];
+	} else {
+		[messageStyle setCustomBackgroundColor:nil];
+	}
+	
+	[messageStyle setCustomBackgroundPath:cachePath];
+	[messageStyle setCustomBackgroundType:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundType" forStyle:activeStyle]
+																				  group:preferenceGroup] intValue]];
+	
+	BOOL isBackgroundTransparent = [[self messageStyle] isBackgroundTransparent];
+	[webView setTransparent:isBackgroundTransparent];
+	NSWindow *win = [webView window];
+	if(win)
+		[win setOpaque:!isBackgroundTransparent];
+	
+	//Update webview font settings
+	NSString	*fontFamily = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontFamily" forStyle:activeStyle]
+																  group:preferenceGroup];
+	[webView setFontFamily:(fontFamily ? fontFamily : [messageStyle defaultFontFamily])];
+	
+	NSNumber	*fontSize = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontSize" forStyle:activeStyle]
+																group:preferenceGroup];
+	[[webView preferences] setDefaultFontSize:[(fontSize ? fontSize : [messageStyle defaultFontSize]) intValue]];
+	
+	NSNumber	*minSize = [adium.preferenceController preferenceForKey:KEY_WEBKIT_MIN_FONT_SIZE
 															   group:preferenceGroup];
-			if (!cachePath || ![[NSFileManager defaultManager] fileExistsAtPath:cachePath]) {
-				NSData	*backgroundImage = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"Background" forStyle:activeStyle]
-																				 group:PREF_GROUP_WEBKIT_BACKGROUND_IMAGES];
-				
-				if (backgroundImage) {
-					//Generate a unique cache ID for this image
-					NSInteger	uniqueID = [[adium.preferenceController preferenceForKey:@"BackgroundCacheUniqueID"
-																				 group:preferenceGroup] integerValue] + 1;
-					[adium.preferenceController setPreference:[NSNumber numberWithInteger:uniqueID]
-													   forKey:@"BackgroundCacheUniqueID"
-														group:preferenceGroup];
-					
-					//Cache the image under that unique ID
-					//Since we prefix the filename with TEMP, Adium will automatically clean it up on quit
-					cachePath = [self _webKitBackgroundImagePathForUniqueID:uniqueID];
-					[backgroundImage writeToFile:cachePath atomically:YES];
-					
-					//Remember where we cached it
-					[adium.preferenceController setPreference:cachePath
-													   forKey:[plugin styleSpecificKey:@"BackgroundCachePath" forStyle:activeStyle]
-														group:preferenceGroup];
-				} else {
-					cachePath = @""; //No custom image found
-				}
-			}
-			
-			[messageStyle setCustomBackgroundColor:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundColor" forStyle:activeStyle]
-																						   group:preferenceGroup] representedColor]];
-		} else {
-			[messageStyle setCustomBackgroundColor:nil];
-		}
-		
-		[messageStyle setCustomBackgroundPath:cachePath];
-		[messageStyle setCustomBackgroundType:[[adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"BackgroundType" forStyle:activeStyle]
-																					  group:preferenceGroup] intValue]];
-		
-		BOOL isBackgroundTransparent = [[self messageStyle] isBackgroundTransparent];
-		[webView setTransparent:isBackgroundTransparent];
-		NSWindow *win = [webView window];
-		if(win)
-			[win setOpaque:!isBackgroundTransparent];
-		
-		//Update webview font settings
-		NSString	*fontFamily = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontFamily" forStyle:activeStyle]
-																	  group:preferenceGroup];
-		[webView setFontFamily:(fontFamily ? fontFamily : [messageStyle defaultFontFamily])];
-		
-		NSNumber	*fontSize = [adium.preferenceController preferenceForKey:[plugin styleSpecificKey:@"FontSize" forStyle:activeStyle]
-																	group:preferenceGroup];
-		[[webView preferences] setDefaultFontSize:[(fontSize ? fontSize : [messageStyle defaultFontSize]) intValue]];
-		
-		NSNumber	*minSize = [adium.preferenceController preferenceForKey:KEY_WEBKIT_MIN_FONT_SIZE
-																   group:preferenceGroup];
-		[[webView preferences] setMinimumFontSize:(minSize ? [minSize intValue] : 1)];
-		[[webView preferences] setMinimumLogicalFontSize:(minSize ? [minSize intValue] : 1)];
-		
+	[[webView preferences] setMinimumFontSize:(minSize ? [minSize intValue] : 1)];
+	[[webView preferences] setMinimumLogicalFontSize:(minSize ? [minSize intValue] : 1)];
+	
+	dispatch_async(dispatch_get_current_queue(), ^{
+		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 		//Update our icons before doing any loading
 		[self sourceOrDestinationChanged:nil];
 		
 		//Prime the webview with the new style/variant and settings, and re-insert all our content back into the view
-		[self _primeWebViewAndReprocessContent:YES];	
+		[self _primeWebViewAndReprocessContent:YES];
+		[pool release];
 	});
 }
 




More information about the commits mailing list