adium 4594:adb332029858: Refactored AINewGroupWindowController t...

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


details:	http://hg.adium.im/adium/rev/adb332029858
revision:	4594:adb332029858
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Sun Jan 29 16:15:42 2012 +0100

Refactored AINewGroupWindowController to be acceptable to the static analyzer, and fix it leaking after closing the window.

diffs (128 lines):

diff -r 7e15eea3d5e1 -r adb332029858 Source/AIAdvancedInspectorPane.m
--- a/Source/AIAdvancedInspectorPane.m	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AIAdvancedInspectorPane.m	Sun Jan 29 16:15:42 2012 +0100
@@ -260,7 +260,8 @@
 #pragma mark Group control
 - (void)addNewGroup:(id)sender
 {
-	AINewGroupWindowController *newGroupController = [AINewGroupWindowController promptForNewGroupOnWindow:inspectorContentView.window];
+	AINewGroupWindowController *newGroupController = [[AINewGroupWindowController alloc] init];
+	[newGroupController showOnWindow:inspectorContentView.window];
 	
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(newGroupControllerDidEnd:)
diff -r 7e15eea3d5e1 -r adb332029858 Source/AIContactListEditorPlugin.m
--- a/Source/AIContactListEditorPlugin.m	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AIContactListEditorPlugin.m	Sun Jan 29 16:15:42 2012 +0100
@@ -252,7 +252,8 @@
  */
 - (IBAction)addGroup:(id)sender
 {
-	[AINewGroupWindowController promptForNewGroupOnWindow:nil];
+	AINewGroupWindowController *newGroupController = [[AINewGroupWindowController alloc] init];
+	[newGroupController showOnWindow:nil];
 }
 
 
diff -r 7e15eea3d5e1 -r adb332029858 Source/AINewBookmarkWindowController.m
--- a/Source/AINewBookmarkWindowController.m	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AINewBookmarkWindowController.m	Sun Jan 29 16:15:42 2012 +0100
@@ -167,10 +167,9 @@
  */
 - (void)newGroup:(id)sender
 {
-	AINewGroupWindowController	*newGroupWindowController;
+	AINewGroupWindowController *newGroupWindowController = [[AINewGroupWindowController alloc] init];
+	[newGroupWindowController showOnWindow:[self window]];
 	
-	newGroupWindowController = [AINewGroupWindowController promptForNewGroupOnWindow:[self window]];
-
 	//Observe for the New Group window to close
 	[[NSNotificationCenter defaultCenter] addObserver:self
 								   selector:@selector(newGroupDidEnd:) 
diff -r 7e15eea3d5e1 -r adb332029858 Source/AINewContactWindowController.m
--- a/Source/AINewContactWindowController.m	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AINewContactWindowController.m	Sun Jan 29 16:15:42 2012 +0100
@@ -446,9 +446,8 @@
  */
 - (void)newGroup:(id)sender
 {
-	AINewGroupWindowController	*newGroupWindowController;
-	
-	newGroupWindowController = [AINewGroupWindowController promptForNewGroupOnWindow:[self window]];
+	AINewGroupWindowController *newGroupWindowController = [[AINewGroupWindowController alloc] init];
+	[newGroupWindowController showOnWindow:[self window]];
 
 	//Observe for the New Group window to close
 	[[NSNotificationCenter defaultCenter] addObserver:self
diff -r 7e15eea3d5e1 -r adb332029858 Source/AINewGroupWindowController.h
--- a/Source/AINewGroupWindowController.h	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AINewGroupWindowController.h	Sun Jan 29 16:15:42 2012 +0100
@@ -27,7 +27,7 @@
 	AIListGroup *group;
 }
 
-+ (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow __attribute__((objc_method_family(new)));
+- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
 - (AIListGroup *)group;
 - (IBAction)cancel:(id)sender;
 - (IBAction)addGroup:(id)sender;
diff -r 7e15eea3d5e1 -r adb332029858 Source/AINewGroupWindowController.m
--- a/Source/AINewGroupWindowController.m	Sun Jan 29 16:04:43 2012 +0100
+++ b/Source/AINewGroupWindowController.m	Sun Jan 29 16:15:42 2012 +0100
@@ -30,28 +30,26 @@
  */
 @implementation AINewGroupWindowController
 
-/*!
- * @brief Prompt for a new group.
- *
- * @param parentWindow Window on which to show as a sheet. Pass nil for a panel prompt.
- */
-+ (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow
+- (id)init
 {
-	AINewGroupWindowController	*newGroupWindowController;
+	if (self = [super initWithWindowNibName:ADD_GROUP_PROMPT_NIB]) {
+		
+	}
 	
-	newGroupWindowController = [[self alloc] initWithWindowNibName:ADD_GROUP_PROMPT_NIB];
-	
+	return self;
+}
+
+- (void)showOnWindow:(NSWindow *)parentWindow
+{
 	if (parentWindow) {
-		[NSApp beginSheet:[newGroupWindowController window]
+		[NSApp beginSheet:self.window
 		   modalForWindow:parentWindow
-			modalDelegate:newGroupWindowController
+			modalDelegate:self
 		   didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
 			  contextInfo:nil];
 	} else {
-		[newGroupWindowController showWindow:nil];
+		[self showWindow:nil];
 	}
-	
-	return newGroupWindowController;
 }
 
 /*!
@@ -78,6 +76,14 @@
 	[[NSNotificationCenter defaultCenter] postNotificationName:@"NewGroupWindowControllerDidEnd"
 											  object:sheet];
     [sheet orderOut:nil];
+	[self autorelease];
+}
+
+- (void)windowWillClose:(id)sender
+{
+	[super windowWillClose:sender];
+	
+	[self autorelease];
 }
 
 /*!




More information about the commits mailing list