adium 4603:47eaa4e45396: Refactor AIListLayoutWindowController t...
commits at adium.im
commits at adium.im
Sun Jan 29 17:12:31 UTC 2012
details: http://hg.adium.im/adium/rev/47eaa4e45396
revision: 4603:47eaa4e45396
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Sun Jan 29 18:12:22 2012 +0100
Refactor AIListLayoutWindowController to be acceptable to the static analyzer, and fix it leaking after closing the window.
diffs (102 lines):
diff -r 86168c4921da -r 47eaa4e45396 Source/AIAppearancePreferences.m
--- a/Source/AIAppearancePreferences.m Sun Jan 29 18:04:23 2012 +0100
+++ b/Source/AIAppearancePreferences.m Sun Jan 29 18:12:22 2012 +0100
@@ -581,9 +581,9 @@
{
NSString *theme = [adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_NAME group:PREF_GROUP_APPEARANCE];
- [AIListLayoutWindowController editListLayoutWithName:theme
- onWindow:[[self view] window]
- notifyingTarget:self];
+ AIListLayoutWindowController *listLayoutWindowController = [[AIListLayoutWindowController alloc] initWithName:theme
+ notifyingTarget:self];
+ [listLayoutWindowController showOnWindow:[[self view] window]];
}
/*!
@@ -691,9 +691,9 @@
[listThemeWindowController showOnWindow:[[self view] window]];
}
- (void)_editListLayoutWithName:(NSString *)name{
- [AIListLayoutWindowController editListLayoutWithName:name
- onWindow:[[self view] window]
- notifyingTarget:self];
+ AIListLayoutWindowController *listLayoutWindowController = [[AIListLayoutWindowController alloc] initWithName:name
+ notifyingTarget:self];
+ [listLayoutWindowController showOnWindow:[[self view] window]];
}
/*!
diff -r 86168c4921da -r 47eaa4e45396 Source/AIListLayoutWindowController.h
--- a/Source/AIListLayoutWindowController.h Sun Jan 29 18:04:23 2012 +0100
+++ b/Source/AIListLayoutWindowController.h Sun Jan 29 18:12:22 2012 +0100
@@ -61,7 +61,8 @@
NSString *layoutName;
}
-+ (id)editListLayoutWithName:(NSString *)inName onWindow:(NSWindow *)parentWindow notifyingTarget:(id)inTarget __attribute__((objc_method_family(new)));
+- (void)showOnWindow:(NSWindow *)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 86168c4921da -r 47eaa4e45396 Source/AIListLayoutWindowController.m
--- a/Source/AIListLayoutWindowController.m Sun Jan 29 18:04:23 2012 +0100
+++ b/Source/AIListLayoutWindowController.m Sun Jan 29 18:12:22 2012 +0100
@@ -28,7 +28,6 @@
@interface AIListLayoutWindowController ()
-- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)inName notifyingTarget:(id)inTarget;
- (void)configureControls;
- (void)configureControlDimming;
- (void)updateSliderValues;
@@ -45,28 +44,22 @@
@implementation AIListLayoutWindowController
-+ (id)editListLayoutWithName:(NSString *)inName onWindow:(NSWindow *)parentWindow notifyingTarget:(id)inTarget
+- (void)showOnWindow:(NSWindow *)parentWindow
{
- AIListLayoutWindowController *listLayoutWindow = [[self alloc] initWithWindowNibName:@"ListLayoutSheet"
- name:inName
- notifyingTarget:inTarget];
-
if (parentWindow) {
- [NSApp beginSheet:[listLayoutWindow window]
+ [NSApp beginSheet:self.window
modalForWindow:parentWindow
- modalDelegate:listLayoutWindow
+ modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
} else {
- [listLayoutWindow showWindow:nil];
+ [self showWindow:nil];
}
-
- return listLayoutWindow;
}
-- (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:@"ListLayoutSheet"])) {
NSParameterAssert(inTarget && [inTarget respondsToSelector:@selector(listLayoutEditorWillCloseWithChanges:forLayoutNamed:)]);
target = inTarget;
@@ -117,6 +110,13 @@
[self autorelease];
}
+- (void)windowWillClose:(id)sender
+{
+ [super windowWillClose:sender];
+
+ [self autorelease];
+}
+
// Cancel
- (IBAction)cancel:(id)sender
{
More information about the commits
mailing list