adium 4592:7a4864a334d0: Refactored AIListThemeWindowController ...

commits at adium.im commits at adium.im
Sun Jan 29 15:00:02 UTC 2012


details:	http://hg.adium.im/adium/rev/7a4864a334d0
revision:	4592:7a4864a334d0
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Sun Jan 29 15:59:53 2012 +0100

Refactored AIListThemeWindowController to be acceptable to the static analyzer.

diffs (102 lines):

diff -r 6810abfa78bc -r 7a4864a334d0 Source/AIAppearancePreferences.m
--- a/Source/AIAppearancePreferences.m	Sun Jan 29 15:49:48 2012 +0100
+++ b/Source/AIAppearancePreferences.m	Sun Jan 29 15:59:53 2012 +0100
@@ -508,9 +508,9 @@
 {
 	NSString *theme = [adium.preferenceController preferenceForKey:KEY_LIST_THEME_NAME group:PREF_GROUP_APPEARANCE];	
 	
-	[AIListThemeWindowController editListThemeWithName:theme
-											  onWindow:[[self view] window]
-									   notifyingTarget:self];
+	AIListThemeWindowController *listThemeWindowController = [[AIListThemeWindowController alloc] initWithName:theme
+																							   notifyingTarget:self];
+	[listThemeWindowController showOnWindow:[[self view] window]];
 }
 
 /*!
@@ -686,9 +686,9 @@
 	}
 }
 - (void)_editListThemeWithName:(NSString *)name{
-	[AIListThemeWindowController editListThemeWithName:name
-											  onWindow:[[self view] window]
-									   notifyingTarget:self];
+	AIListThemeWindowController *listThemeWindowController = [[AIListThemeWindowController alloc] initWithName:name
+																							   notifyingTarget:self];
+	[listThemeWindowController showOnWindow:[[self view] window]];
 }
 - (void)_editListLayoutWithName:(NSString *)name{
 	[AIListLayoutWindowController editListLayoutWithName:name
diff -r 6810abfa78bc -r 7a4864a334d0 Source/AIListThemeWindowController.h
--- a/Source/AIListThemeWindowController.h	Sun Jan 29 15:49:48 2012 +0100
+++ b/Source/AIListThemeWindowController.h	Sun Jan 29 15:59:53 2012 +0100
@@ -98,7 +98,8 @@
 	NSString		*themeName;
 }
 
-+ (id)editListThemeWithName:(NSString *)inName onWindow:(NSWindow *)parentWindow notifyingTarget:(id)inTarget __attribute__((objc_method_family(new)));
+- (void)showOnWindow:(id)parentWindow __attribute__((ns_consumes_self));
+- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget;
 - (IBAction)cancel:(id)sender;
 - (IBAction)okay:(id)sender;
 - (void)preferenceChanged:(id)sender;
diff -r 6810abfa78bc -r 7a4864a334d0 Source/AIListThemeWindowController.m
--- a/Source/AIListThemeWindowController.m	Sun Jan 29 15:49:48 2012 +0100
+++ b/Source/AIListThemeWindowController.m	Sun Jan 29 15:59:53 2012 +0100
@@ -25,7 +25,6 @@
 
 @interface AIListThemeWindowController ()
 
-- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)inName notifyingTarget:(id)inTarget;
 - (void)configureControls;
 - (void)configureControlDimming;
 - (void)updateSliderValues;
@@ -37,28 +36,22 @@
 
 @implementation AIListThemeWindowController
 
-+ (id)editListThemeWithName:(NSString *)inName onWindow:(NSWindow *)parentWindow notifyingTarget:(id)inTarget
+- (void)showOnWindow:(id)parentWindow
 {
-	AIListThemeWindowController	*listThemeWindow = [[self alloc] initWithWindowNibName:@"ListThemeSheet"
-																				  name:inName
-																	   notifyingTarget:inTarget];
-	
 	if (parentWindow) {
-		[NSApp beginSheet:[listThemeWindow window]
+		[NSApp beginSheet:self.window
 		   modalForWindow:parentWindow
-			modalDelegate:listThemeWindow
+			modalDelegate:self
 		   didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
 			  contextInfo:nil];
 	} else {
-		[listThemeWindow showWindow:nil];
+		[self showWindow:nil];
 	}
-	
-	return listThemeWindow;
 }
 
-- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)inName notifyingTarget:(id)inTarget
+- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget
 {
-    if ((self = [super initWithWindowNibName:windowNibName])) {	
+    if ((self = [super initWithWindowNibName:@"ListThemeSheet"])) {	
 		NSParameterAssert(inTarget && [inTarget respondsToSelector:@selector(listThemeEditorWillCloseWithChanges:forThemeNamed:)]);
 	
 		target = inTarget;
@@ -99,6 +92,13 @@
 	[self autorelease];
 }
 
+- (void)windowWillClose:(id)sender
+{
+	[super windowWillClose:sender];
+	
+	[self autorelease];
+}
+
 // Cancel
 - (IBAction)cancel:(id)sender
 {




More information about the commits mailing list