Skip to content

Commit

Permalink
remove debug statements, issue distributed notification on context ch…
Browse files Browse the repository at this point in the history
…ange fixes #142
  • Loading branch information
dustinrue committed Mar 13, 2012
1 parent e7c8ac8 commit 3aeb42a
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Source/CPController.m
Expand Up @@ -435,17 +435,13 @@ - (void)awakeFromNib {
- (void)setStatusTitle:(NSString *)title
{
[menuBarLocker lock];
DSLog(@"setStatusTitle");

if (!sbItem) {
DSLog(@"bailing because sbItem is null");
DSLog(@"unlocking in setStatusTitle");
[menuBarLocker unlock];
return;
}
if (!title) {
[sbItem setTitle:nil];
DSLog(@"bailing because title is null");
DSLog(@"unlocking in setStatusTitle");
[menuBarLocker unlock];
return;
}
Expand All @@ -456,17 +452,17 @@ - (void)setStatusTitle:(NSString *)title
forKey:NSFontAttributeName];
NSAttributedString *as = [[NSAttributedString alloc] initWithString:title attributes:attrs];
[sbItem setAttributedTitle:[as autorelease]];
DSLog(@"unlocking in setStatusTitle");

[menuBarLocker unlock];
}

- (void)setMenuBarImage:(NSImage *)imageName {
DSLog(@"locking in setMenuBarImage");

[menuBarLocker lock];
// if the menu bar item has been hidden sbItem will have been released
// and we should not attempt to update the image
if (!sbItem) {
DSLog(@"unlocking in setMenuBarImage");

[menuBarLocker unlock];
return;
}
Expand All @@ -479,13 +475,13 @@ - (void)setMenuBarImage:(NSImage *)imageName {
DSLog(@"failed to set the menubar icon to %@ with error %@. Please alert ControlPlane Developers!", [imageName name], [exception reason]);
[self setStatusTitle:@"Failed to set icon"];
}
DSLog(@"unlocking in setMenuBarImage");

[menuBarLocker unlock];
}

- (void)showInStatusBar:(id)sender
{
DSLog(@"locking in showInStatusBar");

[menuBarLocker lock];
if (sbItem) {
// Already there? Rebuild it anyway.
Expand All @@ -496,7 +492,7 @@ - (void)showInStatusBar:(id)sender
sbItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[sbItem retain];
[sbItem setHighlightMode:YES];
DSLog(@"unlocking in showInStatusBar");

[menuBarLocker unlock];

// only show the icon if preferences say we should
Expand All @@ -516,14 +512,14 @@ - (void)showInStatusBar:(id)sender
}

- (void)hideFromStatusBar:(NSTimer *)theTimer {
DSLog(@"locking in hideFromStatusBar");

[menuBarLocker lock];

sbHideTimer = [sbHideTimer checkAndInvalidate];

[self doHideFromStatusBar:NO];

DSLog(@"unlocking in hideFromStatusBar");

[menuBarLocker unlock];
}

Expand Down Expand Up @@ -882,8 +878,6 @@ - (void)performTransitionFrom:(NSString *)fromUUID to:(NSString *)toUUID
Context *ctxt;

[updatingSwitchingLock lock];



// Execute all the "Departure" actions
en = [leaving_walk objectEnumerator];
Expand All @@ -896,6 +890,13 @@ - (void)performTransitionFrom:(NSString *)fromUUID to:(NSString *)toUUID
[self setValue:toUUID forKey:@"currentContextUUID"];
NSString *ctxt_path = [contextsDataSource pathFromRootTo:toUUID];

NSString *notificationObject = [[NSBundle mainBundle] bundleIdentifier];
NSString *notificationName = [NSString stringWithFormat:@"%@.ContextChanged",notificationObject];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:ctxt_path, @"context", nil];

NSDistributedNotificationCenter *dnc = [NSDistributedNotificationCenter defaultCenter];
[dnc postNotificationName:notificationName object:notificationObject userInfo:userInfo deliverImmediately:YES];

// Create context named 'Developer Crash' and CP will crash when moving to it if using a DEBUG build
// Allows you to test QuinyKit
if ([ctxt_path isEqualToString:@"Developer Crash"]) {
Expand Down

0 comments on commit 3aeb42a

Please sign in to comment.