adium 4588:5f944dc6405a: Fix a couple of leaks and incorrect mem...
commits at adium.im
commits at adium.im
Sun Jan 29 14:13:59 UTC 2012
details: http://hg.adium.im/adium/rev/5f944dc6405a
revision: 4588:5f944dc6405a
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Sun Jan 29 15:11:57 2012 +0100
Fix a couple of leaks and incorrect memory management in AIEmoticonPreferences, also, create and open it in a way the static analyzer will accept.
diffs (117 lines):
diff -r 12a395ffc9a7 -r 5f944dc6405a Plugins/Emoticons/AIEmoticonPreferences.h
--- a/Plugins/Emoticons/AIEmoticonPreferences.h Sun Jan 29 14:55:46 2012 +0200
+++ b/Plugins/Emoticons/AIEmoticonPreferences.h Sun Jan 29 15:11:57 2012 +0100
@@ -38,7 +38,7 @@
BOOL viewIsOpen;
}
-+ (void)showEmoticionCustomizationOnWindow:(NSWindow *)parentWindow;
+- (void)openOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
- (void)toggledPackController:(id)packController;
- (void)emoticonXtrasDidChange;
diff -r 12a395ffc9a7 -r 5f944dc6405a Plugins/Emoticons/AIEmoticonPreferences.m
--- a/Plugins/Emoticons/AIEmoticonPreferences.m Sun Jan 29 14:55:46 2012 +0200
+++ b/Plugins/Emoticons/AIEmoticonPreferences.m Sun Jan 29 15:11:57 2012 +0100
@@ -44,21 +44,26 @@
@implementation AIEmoticonPreferences
-+ (void)showEmoticionCustomizationOnWindow:(NSWindow *)parentWindow
+- (id)init
{
- AIEmoticonPreferences *controller;
+ if (self = [super initWithWindowNibName:@"EmoticonPrefs"]) {
+
+ }
- controller = [[self alloc] initWithWindowNibName:@"EmoticonPrefs"];
-
+ return self;
+}
+
+- (void)openOnWindow:(NSWindow *)parentWindow
+{
if (parentWindow) {
- [NSApp beginSheet:[controller window]
+ [NSApp beginSheet:self.window
modalForWindow:parentWindow
- modalDelegate:controller
+ modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
} else {
- [controller showWindow:nil];
- [[controller window] makeKeyAndOrderFront:nil];
+ [self showWindow:nil];
+ [self.window makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
}
}
@@ -68,7 +73,8 @@
*/
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
- [sheet orderOut:nil];
+ [sheet orderOut:nil];
+ [sheet close];
}
//Configure the preference view
@@ -87,6 +93,7 @@
[self configurePreviewControllers];
//Emoticons table
+ [selectedEmoticonPack release];
selectedEmoticonPack = nil;
checkCell = [[NSButtonCell alloc] init];
[checkCell setButtonType:NSSwitchButton];
@@ -94,7 +101,6 @@
[checkCell setTitle:@""];
[checkCell setRefusesFirstResponder:YES];
[[table_emoticons tableColumnWithIdentifier:@"Enabled"] setDataCell:checkCell];
- [checkCell release];
NSImageCell *imageCell = [[NSImageCell alloc] initImageCell:nil];
if ([imageCell respondsToSelector:@selector(_setAnimates:)]) [imageCell _setAnimates:NO];
@@ -131,15 +137,23 @@
- (void)windowWillClose:(id)sender
{
viewIsOpen = NO;
+
+ [super windowWillClose:sender];
+
+ [adium.preferenceController unregisterPreferenceObserver:self];
+ [adium.emoticonController flushEmoticonImageCache];
+
+ [self autorelease];
+}
+- (void)dealloc
+{
[checkCell release]; checkCell = nil;
[selectedEmoticonPack release]; selectedEmoticonPack = nil;
[emoticonPackPreviewControllers release]; emoticonPackPreviewControllers = nil;
- [adium.preferenceController unregisterPreferenceObserver:self];
[emoticonImageCache release]; emoticonImageCache = nil;
-
- //Flush all the images we loaded
- [adium.emoticonController flushEmoticonImageCache];
+
+ [super dealloc];
}
- (void)configurePreviewControllers
diff -r 12a395ffc9a7 -r 5f944dc6405a Source/AIAppearancePreferences.m
--- a/Source/AIAppearancePreferences.m Sun Jan 29 14:55:46 2012 +0200
+++ b/Source/AIAppearancePreferences.m Sun Jan 29 15:11:57 2012 +0100
@@ -394,7 +394,8 @@
*/
- (IBAction)customizeEmoticons:(id)sender
{
- [AIEmoticonPreferences showEmoticionCustomizationOnWindow:[[self view] window]];
+ AIEmoticonPreferences *emoticonPreferences = [[AIEmoticonPreferences alloc] init];
+ [emoticonPreferences openOnWindow:[[self view] window]];
}
/*!
More information about the commits
mailing list