All AIWindowControllers that are not retained by their creator now end up in a set, where they are removed from once they close. This solution should be ARCceptable.
--- a/Frameworks/Adium Framework/Source/AIWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/AIWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -17,6 +17,8 @@
@interface AIWindowController : NSWindowController <NSWindowDelegate> {
+- (void)showOnWindow:(id)parentWindow; +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; - (IBAction)closeWindow:(id)sender;
- (BOOL)windowShouldClose:(id)sender;
- (NSString *)adiumFrameAutosaveName;
--- a/Frameworks/Adium Framework/Source/AIWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/AIWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -32,6 +32,16 @@
@implementation AIWindowController
++ (NSMutableSet *)independentWindows { + static NSMutableSet *independentWindows; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + independentWindows = [[NSMutableSet alloc] init]; + return independentWindows; if ([self isEqual:[AIWindowController class]]) {
@@ -61,6 +71,37 @@
+ * @param parentWindow A window on which to show the edit account window as a sheet. If nil, account editing takes place in an independent window. +- (void)showOnWindow:(id)parentWindow + [NSApp beginSheet:self.window + modalForWindow:parentWindow + didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + [[AIWindowController independentWindows] addObject:self]; + * @brief Called as the user list edit sheet closes, dismisses the sheet +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo + [[AIWindowController independentWindows] removeObject:self]; @@ -287,6 +328,8 @@
forKey:[self multiscreenKeyWithAutosaveName:key]
group:PREF_GROUP_WINDOW_POSITIONS];
+ [[AIWindowController independentWindows] removeObject:self]; --- a/Frameworks/Adium Framework/Source/ESPresetManagementController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESPresetManagementController.h Wed Sep 12 01:36:08 2012 +0200
@@ -35,7 +35,6 @@
- (id)initWithPresets:(NSArray *)inPresets namedByKey:(NSString *)inNameKey withDelegate:(id)inDelegate;
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (IBAction)duplicatePreset:(id)sender;
- (IBAction)deletePreset:(id)sender;
--- a/Frameworks/Adium Framework/Source/ESPresetManagementController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESPresetManagementController.m Wed Sep 12 01:36:08 2012 +0200
@@ -21,7 +21,6 @@
@interface ESPresetManagementController ()
- (void)configureControlDimming;
- (void)tableViewSelectionDidChange:(NSNotification *)notification;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@@ -32,15 +31,9 @@
- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
+ [super showOnWindow:parentWindow]; [self.window makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
@@ -106,29 +99,10 @@
- (IBAction)okay:(id)sender
- * Invoked as the sheet closes, dismiss the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
- * @brief As the window closes, release this controller instance
- * The instance retained itself (rather, was not autoreleased when created) so it could function independently.
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
* @brief Duplicate the selected preset
- (IBAction)duplicatePreset:(id)sender
--- a/Frameworks/Adium Framework/Source/ESPresetNameSheetController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESPresetNameSheetController.h Wed Sep 12 01:36:08 2012 +0200
@@ -36,7 +36,6 @@
- (id)initWithDefaultName:(NSString *)inDefaultName explanatoryText:(NSString *)inExplanatoryText notifyingTarget:(id)inTarget userInfo:(id)inUserInfo;
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (IBAction)okay:(id)sender;
- (IBAction)cancel:(id)sender;
--- a/Frameworks/Adium Framework/Source/ESPresetNameSheetController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESPresetNameSheetController.m Wed Sep 12 01:36:08 2012 +0200
@@ -20,7 +20,6 @@
@interface ESPresetNameSheetController ()
- (void)configureExplanatoryTextWithString:(NSString *)inExplanatoryText;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@implementation ESPresetNameSheetController
@@ -30,11 +29,7 @@
//Must be called on a window
NSParameterAssert(parentWindow != nil);
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
+ [super showOnWindow:parentWindow]; - (id)initWithDefaultName:(NSString *)inDefaultName explanatoryText:(NSString *)inExplanatoryText notifyingTarget:(id)inTarget userInfo:(id)inUserInfo
@@ -52,24 +47,6 @@
- * @brief Invoked as the sheet closes, dismiss the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
-* @brief As the window closes, release this controller instance
- * The instance retained itself (rather, was not autoreleased when created) so it could function independently.
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
- (IBAction)okay:(id)sender
NSString *newName = [textField_name stringValue];
--- a/Frameworks/Adium Framework/Source/ESTextAndButtonsWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESTextAndButtonsWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -65,8 +65,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (void)changeWindowToTitle:(NSString *)inTitle
defaultButton:(NSString *)inDefaultButton
alternateButton:(NSString *)inAlternateButton
--- a/Frameworks/Adium Framework/Source/ESTextAndButtonsWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Frameworks/Adium Framework/Source/ESTextAndButtonsWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -20,7 +20,6 @@
@interface ESTextAndButtonsWindowController ()
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@implementation ESTextAndButtonsWindowController
@@ -86,20 +85,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- (id)initWithTitle:(NSString *)inTitle
defaultButton:(NSString *)inDefaultButton
alternateButton:(NSString *)inAlternateButton
@@ -250,18 +235,10 @@
- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
//Release our target immediately to avoid a potential mutual retain (if the target is retaining us)
- * @brief Invoked as the sheet closes, dismiss the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+ [super windowWillClose:sender]; --- a/Plugins/Link Management/SHLinkEditorWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Plugins/Link Management/SHLinkEditorWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -43,7 +43,6 @@
- (id)initWithTextView:(NSTextView *)inTextView notifyingTarget:(id)inTarget;
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (IBAction)cancel:(id)sender;
- (IBAction)acceptURL:(id)sender;
--- a/Plugins/Link Management/SHLinkEditorWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Plugins/Link Management/SHLinkEditorWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -28,8 +28,6 @@
- (void)insertLinkTo:(NSURL *)urlString withText:(NSString *)linkString inView:(NSTextView *)inView;
- (void)informTargetOfLink;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@interface NSObject (SHLinkEditorAdditions)
@@ -42,19 +40,6 @@
#pragma mark Init methods
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- (id)initWithTextView:(NSTextView *)inTextView notifyingTarget:(id)inTarget
@@ -157,18 +142,6 @@
[scrollView_URL setAlwaysDrawFocusRingIfFocused:YES];
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
-// Called as the sheet closes, dismisses the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
- (IBAction)cancel:(id)sender
--- a/Source/AIEditAccountWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIEditAccountWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -48,8 +48,6 @@
-- (void)showOnWindow:(id)parentWindow __attribute__((ns_consumes_self));
- (id)initWithAccount:(AIAccount *)inAccount notifyingTarget:(id)inTarget;
- (IBAction)cancel:(id)sender;
- (IBAction)okay:(id)sender;
--- a/Source/AIEditAccountWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIEditAccountWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -37,8 +37,6 @@
- (void)_localizeTabViewItemLabels;
- (void)saveConfiguration;
- (void)configureControlDimming;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
@@ -48,24 +46,6 @@
@implementation AIEditAccountWindowController
- * @param parentWindow A window on which to show the edit account window as a sheet. If nil, account editing takes place in an independent window.
-- (void)showOnWindow:(id)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
* @brief Init the window controller
- (id)initWithAccount:(AIAccount *)inAccount notifyingTarget:(id)inTarget
@@ -131,22 +111,6 @@
[notifyTarget editAccountWindow:[self window] didOpenForAccount:account];
- * @brief Window is closing
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
- * @brief Called as the user list edit sheet closes, dismisses the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
- (void)configureControlDimming
BOOL enableUserIcon = ([[matrix_userIcon selectedCell] tag] == 1);
--- a/Source/AIListLayoutWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIListLayoutWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -61,7 +61,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget;
- (IBAction)cancel:(id)sender;
- (IBAction)okay:(id)sender;
--- a/Source/AIListLayoutWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIListLayoutWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -44,19 +44,6 @@
@implementation AIListLayoutWindowController
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget
if ((self = [super initWithWindowNibName:@"ListLayoutSheet"])) {
@@ -90,17 +77,12 @@
// Called as the sheet closes, dismisses the sheet
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
[[NSColorPanel sharedColorPanel] close];
// No longer allow alpha in our color pickers
[[NSColorPanel sharedColorPanel] setShowsAlpha:NO];
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
+ [super sheetDidEnd:sheet returnCode:returnCode contextInfo:contextInfo]; --- a/Source/AIListThemeWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIListThemeWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -98,7 +98,6 @@
-- (void)showOnWindow:(id)parentWindow __attribute__((ns_consumes_self));
- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget;
- (IBAction)cancel:(id)sender;
- (IBAction)okay:(id)sender;
--- a/Source/AIListThemeWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AIListThemeWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -36,19 +36,6 @@
@implementation AIListThemeWindowController
-- (void)showOnWindow:(id)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- (id)initWithName:(NSString *)inName notifyingTarget:(id)inTarget
if ((self = [super initWithWindowNibName:@"ListThemeSheet"])) {
@@ -76,17 +63,12 @@
// Called as the sheet closes, dismisses the sheet
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
[[NSColorPanel sharedColorPanel] close];
// No longer allow alpha in our color pickers
[[NSColorPanel sharedColorPanel] setShowsAlpha:NO];
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
+ [super sheetDidEnd:sheet returnCode:returnCode contextInfo:contextInfo]; --- a/Source/AINewBookmarkWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewBookmarkWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -32,7 +32,6 @@
- (id)initWithChat:(AIChat *)inChat notifyingTarget:(id)inTarget;
-- (void)showOnWindow:(id)parentWindow __attribute__((ns_consumes_self));
- (IBAction)add:(id)sender;
- (IBAction)cancel:(id)sender;
--- a/Source/AINewBookmarkWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewBookmarkWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -34,25 +34,10 @@
- (void)newGroup:(id)sender;
- (void)newGroupDidEnd:(NSNotification *)inNotification;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
@implementation AINewBookmarkWindowController
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- [self.window makeKeyAndOrderFront:nil];
- (id)initWithChat:(AIChat *)inChat notifyingTarget:(id)inTarget
if ((self = [super initWithWindowNibName:ADD_BOOKMARK_NIB])) {
@@ -64,19 +49,6 @@
- * @brief didEnd selector for the sheet created above, dismisses the sheet
--(void)sheetDidEnd:(NSWindow*)sheet returnCode:(NSInteger)returnCode contextInfo:(void*)contextInfo
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
* @brief the sheet finished loading, populate the group menu with contactlist's groups
--- a/Source/AINewContactWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewContactWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -51,7 +51,6 @@
- (id)initWithContactName:(NSString *)inName service:(AIService *)inService account:(AIAccount *)inAccount;
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (IBAction)cancel:(id)sender;
- (IBAction)addContact:(id)sender;
- (IBAction)searchInAB:(id)sender;
--- a/Source/AINewContactWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewContactWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -37,8 +37,6 @@
#define DEFAULT_GROUP_NAME AILocalizedString(@"Contacts",nil)
@interface AINewContactWindowController ()
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (void)buildContactTypeMenu;
- (void)configureForCurrentServiceType;
@@ -63,16 +61,11 @@
- (void)showOnWindow:(NSWindow *)parentWindow
+ [super showOnWindow:parentWindow]; [parentWindow makeKeyAndOrderFront:nil];
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
[self.window makeKeyAndOrderFront:nil];
@@ -145,22 +138,6 @@
- * @brief Window is closing
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
- * @brief Called as the user list edit sheet closes, dismisses the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
- (IBAction)cancel:(id)sender
--- a/Source/AINewGroupWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewGroupWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -27,7 +27,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (IBAction)cancel:(id)sender;
- (IBAction)addGroup:(id)sender;
--- a/Source/AINewGroupWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/AINewGroupWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -39,19 +39,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
* @brief Setup the window before it is displayed
@@ -75,12 +62,8 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"NewGroupWindowControllerDidEnd"
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
+ [super sheetDidEnd:sheet returnCode:returnCode contextInfo:contextInfo]; --- a/Source/ESEditStatusGroupWindowController.h Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/ESEditStatusGroupWindowController.h Wed Sep 12 01:36:08 2012 +0200
@@ -32,7 +32,6 @@
-- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (id)initWithStatusGroup:(AIStatusGroup *)inStatusGroup notifyingTarget:(id)inTarget;
- (IBAction)okay:(id)sender;
--- a/Source/ESEditStatusGroupWindowController.m Wed Sep 12 00:49:10 2012 +0200
+++ b/Source/ESEditStatusGroupWindowController.m Wed Sep 12 01:36:08 2012 +0200
@@ -23,25 +23,10 @@
@interface ESEditStatusGroupWindowController ()
- (NSMenu *)groupWithStatusMenu;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
@implementation ESEditStatusGroupWindowController
-- (void)showOnWindow:(NSWindow *)parentWindow
- [NSApp beginSheet:self.window
- modalForWindow:parentWindow
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- [self.window makeKeyAndOrderFront:nil];
- (id)initWithStatusGroup:(AIStatusGroup *)inStatusGroup notifyingTarget:(id)inTarget
if ((self = [super initWithWindowNibName:@"EditStatusGroup"])) {
@@ -75,26 +60,6 @@
- * @brief Called before the window is closed
- * As our window is closing, we auto-release this window controller instance. This allows our editor to function
- * independently without needing a separate object to retain and release it.
-- (void)windowWillClose:(id)sender
- [super windowWillClose:sender];
- * Invoked as the sheet closes, dismiss the sheet
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
* Save changes, notify our target of the new configuration, and close the editor.