Skip to content
Browse files

Added support for traditioanl retain/release memory management

  • Loading branch information...
1 parent 2bda92a commit 45192c26b1060cd849478bec656c703fae60faf7 @justin justin committed
View
2 README.markdown
@@ -16,7 +16,7 @@ SGHotKeysLib does the following:
* Adopts Objective-C 2.0 syntax, properties and other language features (suck it dot syntax haters)
* Uses Leopard's Text Input Sources (no patching required)
* Runs natively in 64 bit
-* Requires Garbage Collection
+* Supports Garbage Collection
* Removes legacy code support (no more checking for 10.1, no more Project Builder)
* Cleans up the code formatting & variable declarations
* Puts the code on Github for hot forking action
View
8 SGHotKeysLib/SGHotKey.m
@@ -18,6 +18,14 @@ @implementation SGHotKey
@synthesize action;
@synthesize hotKeyID;
+- (void)dealloc {
+ [identifier release];
+ [name release];
+ [keyCombo release];
+ [target release];
+ [super dealloc];
+}
+
- (id)init {
return [self initWithIdentifier:nil keyCombo:nil target:nil action:nil];
}
View
5 SGHotKeysLib/SGHotKeyCenter.m
@@ -26,6 +26,11 @@ - (void)_hotKeyUp: (SGHotKey *)hotKey;
@implementation SGHotKeyCenter
+- (void)dealloc {
+ [hotKeys release];
+ [super dealloc];
+}
+
+ (SGHotKeyCenter *)sharedCenter {
static SGHotKeyCenter *sharedCenter = nil;
View
5 SGHotKeysLib/SGKeyCodeTranslator.m
@@ -17,7 +17,10 @@ + (id)currentTranslator {
static SGKeyCodeTranslator *currentTranslator = nil;
TISInputSourceRef currentKeyboardLayout = TISCopyCurrentKeyboardInputSource();
- if (currentTranslator == nil || [currentTranslator keyboardLayout] != currentKeyboardLayout) {
+ if (currentTranslator == nil) {
+ currentTranslator = [[SGKeyCodeTranslator alloc] initWithKeyboardLayout:currentKeyboardLayout];
+ } else if ([currentTranslator keyboardLayout] != currentKeyboardLayout) {
+ [currentTranslator release];
currentTranslator = [[SGKeyCodeTranslator alloc] initWithKeyboardLayout:currentKeyboardLayout];
}
View
2 SGHotKeysLib/SGKeyCombo.m
@@ -23,7 +23,7 @@ + (id)clearKeyCombo {
}
+ (id)keyComboWithKeyCode:(NSInteger)theKeyCode modifiers:(NSInteger)theModifiers {
- return [[self alloc] initWithKeyCode:theKeyCode modifiers:theModifiers];
+ return [[[self alloc] initWithKeyCode:theKeyCode modifiers:theModifiers] autorelease];
}
View
10 Source/SGHotKeyCenterAppDelegate.m
@@ -18,10 +18,18 @@ @implementation SGHotKeyCenterAppDelegate
@synthesize resultsTextField;
@synthesize hotKey;
+- (void)dealloc {
+ [window release];
+ [hotKeyControl release];
+ [resultsTextField release];
+ [hotKey release];
+ [super dealloc];
+}
+
- (void)applicationDidFinishLaunching:(NSNotification *)theNotification {
[[SGHotKeyCenter sharedCenter] unregisterHotKey:hotKey];
id keyComboPlist = [[NSUserDefaults standardUserDefaults] objectForKey:kGlobalHotKey];
- SGKeyCombo *keyCombo = [[SGKeyCombo alloc] initWithPlistRepresentation:keyComboPlist];
+ SGKeyCombo *keyCombo = [[[SGKeyCombo alloc] initWithPlistRepresentation:keyComboPlist] autorelease];
hotKey = [[SGHotKey alloc] initWithIdentifier:kGlobalHotKey keyCombo:keyCombo target:self action:@selector(hotKeyPressed:)];
[[SGHotKeyCenter sharedCenter] registerHotKey:hotKey];
[hotKeyControl setKeyCombo:SRMakeKeyCombo(hotKey.keyCombo.keyCode, [hotKeyControl carbonToCocoaFlags:hotKey.keyCombo.modifiers])];

0 comments on commit 45192c2

Please sign in to comment.
Something went wrong with that request. Please try again.