Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug compiling #334

Merged
merged 9 commits into from
Jun 14, 2011
5 changes: 3 additions & 2 deletions Quicksilver/Code-App/QSAdvancedPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ - (NSCell *)tableView:(NSTableView *)aTableView dataCellForTableColumn:(NSTableC
thisInfo = [[prefSetsController arrangedObjects] objectAtIndex:rowIndex];
}
@catch (NSException * e) {
if (DEBUG)
NSLog(@"*** Unhandled Exception:%@ with reason: %@, in %@", [e name], [e reason], NSStringFromSelector(_cmd));
#ifdef DEBUG
NSLog(@"*** Unhandled Exception:%@ with reason: %@, in %@", [e name], [e reason], NSStringFromSelector(_cmd));
#endif
}
NSCell *cell;

Expand Down
11 changes: 9 additions & 2 deletions Quicksilver/Code-App/QSApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ - (void)_sendFinishLaunchingNotification;

@implementation QSApp
+(void)load {
if (DEBUG)
#ifdef DEBUG
setenv("verbose", "1", YES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line still needed? It looks like previously, you could get verbose mode by either the environment variable or by holding down Option. Now it looks like the Option key trick should only be available in Debug builds, which is fine, but in that case, verbose will get set on line 29.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's similar to how it used to be, but I agree - it is a bit funny.
If you're not holding down the ⌥ key then the verbose env gets set then removed. I guess lines 26 and 33 - 35 could be removed.

P.S. did you delete a line comment about #ifndef? That's supposed to be #ifndef since it's replacing an if(!DEBUG) - i.e. only include the code if we're doing a release build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you delete a line comment about #ifndef?

Yes. Just my ignorance of C syntax. Ignore. :)

else if (mOptionKeyIsDown) {
if(mOptionKeyIsDown) {
NSLog(@"Setting Verbose");
setenv("verbose", "1", YES);
setenv("QSDebugPlugIns", "1", YES);
Expand All @@ -33,12 +33,17 @@ +(void)load {
} else {
unsetenv("verbose");
}
#endif
}

+ (void)initialize {
static BOOL done = NO;
if(!done) {

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"App Initialize");
#endif

[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents/QSDefaults.plist"]]];
done = YES;
}
Expand Down Expand Up @@ -139,8 +144,10 @@ - (void)sendEvent:(NSEvent *)theEvent {
break;
case NSOtherMouseDown:
[theEvent retain];
#ifdef DEBUG
if (VERBOSE)
NSLog(@"OtherMouse %@ %@", theEvent, [theEvent window]);
#endif
[[NSClassFromString(@"QSMouseTriggerManager") sharedInstance] handleMouseTriggerEvent:theEvent type:nil forView:nil];
break;
case NSScrollWheel: {
Expand Down
14 changes: 12 additions & 2 deletions Quicksilver/Code-App/QSCatalogPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,16 @@ - (IBAction)selectContentsItem:(id)sender {
}

- (BOOL)selectedCatalogEntryIsEditable {

#ifdef DEBUG
return YES;
#endif

id source = [currentItem source];
if ([source respondsToSelector:@selector(usesGlobalSettings)] && [source performSelector:@selector(usesGlobalSettings)])
return YES;
else
return (![currentItem isPreset] || DEBUG);
return (![currentItem isPreset]);
}

- (void)updateEntrySelection {
Expand Down Expand Up @@ -521,7 +526,12 @@ - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NS
}

- (void)populateCatalogEntryFields {
[itemIconField setEnabled:(currentItem && ![currentItem isPreset]) || DEBUG];

#ifdef DEBUG
[itemIconField setEnabled:YES];
#endif

[itemIconField setEnabled:(currentItem && ![currentItem isPreset])];
[itemIconField setImage:[currentItem icon]];
}

Expand Down
2 changes: 2 additions & 0 deletions Quicksilver/Code-App/QSController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
- (void)openURL:(NSURL *)url;
- (void)showSplash:sender;

#ifdef DEBUG
- (void)activateDebugMenu;
#endif

- (NSMenu *)statusMenuWithQuit;
- (void)activateInterface:(id)sender;
Expand Down
84 changes: 69 additions & 15 deletions Quicksilver/Code-App/QSController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ + (id)sharedInstance {
}

+ (void)initialize {

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Controller Initialize");
#endif

static BOOL initialized = NO;
if (initialized) return;
initialized = YES;

#ifdef DEBUG
if (QSGetLocalizationStatus() && DEBUG_STARTUP) NSLog(@"Enabling Localization");
#endif

[NSApp registerServicesMenuSendTypes:[NSArray arrayWithObjects:NSStringPboardType, NSRTFPboardType, nil] returnTypes:[NSArray arrayWithObjects:NSStringPboardType, NSRTFPboardType, nil]];

Expand All @@ -52,8 +58,10 @@ + (void)initialize {
[defaultActionImage setCacheMode:NSImageCacheNever];
#endif

#ifdef DEBUG
if (defaultBool(@"verbose") )
setenv("verbose", "1", YES);
#endif

// Pre instantiate to avoid bug
// [NSColor controlShadowColor];
Expand Down Expand Up @@ -92,7 +100,10 @@ - (NSString *)applicationSupportFolder {

- (id)init {
if (self = [super init]) {

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Controller Init");
#endif

// Enforce Expiration Date
//Check if a devopment version has expired
Expand Down Expand Up @@ -156,6 +167,7 @@ - (void)setShowMenuIcon:(NSNumber *)mode {
[statusItem setHighlightMode:YES];
}

#ifdef DEBUG
- (void)activateDebugMenu {
NSLog(@"debug menu");
NSMenu *debugMenu = [[[NSMenu alloc] initWithTitle:@"Debug"] autorelease];
Expand Down Expand Up @@ -195,7 +207,7 @@ - (void)activateDebugMenu {
[debugMenuItem setSubmenu:debugMenu];

}

#endif
- (void)raiseException {
[NSException raise:@"Test Exception" format:@"This is a test. It is only a test. In the event of a real exception, it would have been followed by some witty commentary."];
}
Expand Down Expand Up @@ -482,11 +494,15 @@ - (void)handlePasteboardDrop:(NSPasteboard *)pb commandPath:(NSString *)path {

- (void)executeCommandAtPath:(NSString *)path { [[QSCommand commandWithFile:path] execute]; }
- (void)performService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error {
#ifdef DEBUG
if (VERBOSE) NSLog(@"Perform Service: %@ %d", userData, [userData characterAtIndex:0]);
#endif
[self receiveObject:[[[QSObject alloc] initWithPasteboard:pboard] autorelease]];
}
- (void)getSelection:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error {
#ifdef DEBUG
if (VERBOSE) NSLog(@"GetSel Service: %@ %d", userData, [userData characterAtIndex:0]);
#endif
[self receiveObject:[[[QSObject alloc] initWithPasteboard:pboard] autorelease]];
}

Expand Down Expand Up @@ -582,7 +598,11 @@ - (IBAction)forceRescanItems:sender { [QSLib startThreadedAndForcedScan]; }

- (void)delayedStartup {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Delayed Startup");
#endif

[NSThread setThreadPriority:0.0];
QSTask *task = [QSTask taskWithIdentifier:@"QSDelayedStartup"];
[task setStatus:@"Updating Catalog"];
Expand Down Expand Up @@ -611,12 +631,16 @@ - (void)checkForFirstRun {
if (selection)
[NSApp relaunchAtPath:lastLocation movedFromPath:bundlePath];
}
if ([defaults boolForKey:kShowReleaseNotesOnUpgrade] && (!DEBUG) ) {

#ifndef DEBUG
if ([defaults boolForKey:kShowReleaseNotesOnUpgrade]) {
[NSApp activateIgnoringOtherApps:YES];
int selection = NSRunInformationalAlertPanel([NSString stringWithFormat:@"Quicksilver has been updated", nil] , @"You are using a new version of Quicksilver. Would you like to see the Release Notes?", @"Show Release Notes", @"Ignore", nil);
if (selection == 1)
[self showReleaseNotes:self];
}
#endif

[[NSWorkspace sharedWorkspace] setComment:@"Quicksilver" forFile:[[NSBundle mainBundle] bundlePath]];
if (lastVersion < [@"2000" hexIntValue]) {
NSFileManager *fm = [NSFileManager defaultManager];
Expand Down Expand Up @@ -722,9 +746,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification {

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
QSGetLocalizationStatus();
if (DEBUG) {
[self registerForErrors];
}
#ifdef DEBUG
[self registerForErrors];
#endif
}

- (void)setupSplash {
Expand All @@ -750,25 +774,34 @@ - (void)startQuicksilver:(id)sender {
if (!atLogin)
[self setupSplash];

#ifdef DEBUG
if (DEBUG_STARTUP)
NSLog(@"Instantiate Classes");

#endif

[QSRegistry sharedInstance];


#ifdef DEBUG
if (DEBUG_STARTUP)
NSLog(@"Registry loaded");
#endif

[QSMnemonics sharedInstance];
[QSLibrarian sharedInstance];
[QSExecutor sharedInstance];
[QSTaskController sharedInstance];


#ifdef DEBUG
if (DEBUG_STARTUP)
NSLog(@"Library loaded");
#endif

[[QSPlugInManager sharedInstance] loadPlugInsAtLaunch];

#ifdef DEBUG
if (DEBUG_STARTUP)
NSLog(@"PlugIns loaded");
#endif

[[QSLibrarian sharedInstance] initCatalog];

Expand All @@ -779,13 +812,16 @@ - (void)startQuicksilver:(id)sender {

[[QSLibrarian sharedInstance] reloadIDDictionary:nil];
[[QSLibrarian sharedInstance] enableEntries];


#ifdef DEBUG
if (DEBUG_STARTUP)
NSLog(@"Catalog loaded");
#endif

[QSObject purgeIdentifiers];

if (newVersion && (!DEBUG) ) {
#ifndef DEBUG
if (newVersion) {
if (!runningSetupAssistant) {
NSLog(@"New Version: Purging all Identifiers and Forcing Rescan");
[QSLibrarian removeIndexes];
Expand All @@ -794,7 +830,12 @@ - (void)startQuicksilver:(id)sender {
} else {
[[QSLibrarian sharedInstance] loadCatalogArrays];
}

#endif

#ifdef DEBUG
[[QSLibrarian sharedInstance] loadCatalogArrays];
#endif

[[QSLibrarian sharedInstance] reloadEntrySources:nil];

if (atLogin)
Expand Down Expand Up @@ -841,22 +882,31 @@ - (void)startQuicksilver:(id)sender {
int rescanInterval = [defaults integerForKey:@"QSCatalogRescanFrequency"];

if (rescanInterval>0) {

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Rescanning every %d minutes", rescanInterval);
#endif

[NSTimer scheduledTimerWithTimeInterval:rescanInterval*60 target:self selector:@selector(rescanItems:) userInfo:nil repeats:YES];
}

#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Register for Notifications");
#endif

NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[[ws notificationCenter] addObserver:self selector:@selector(appLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];
[[ws notificationCenter] addObserver:self selector:@selector(appWillLaunch:) name:NSWorkspaceWillLaunchApplicationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appChanged:) name:QSActiveApplicationChanged object:nil];

[[[NSApp mainMenu] itemAtIndex:0] setTitle:@"Quicksilver"];


#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Will Finish Launching");

if (DEBUG || PRERELEASEVERSION)
if (PRERELEASEVERSION)
[self activateDebugMenu];
#endif

if (runningSetupAssistant) {
[self hideSplash:nil];
Expand All @@ -868,8 +918,10 @@ - (void)startQuicksilver:(id)sender {

[QSResourceManager sharedInstance];
[[QSTriggerCenter sharedInstance] activateTriggers];


#ifdef DEBUG
if (DEBUG_STARTUP) NSLog(@"Did Finish Launching\n ");
#endif

[self bind:@"showMenuIcon" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:@"values.QSShowMenuIcon" options:nil];

Expand All @@ -879,8 +931,10 @@ - (void)startQuicksilver:(id)sender {
if ( ! (runningSetupAssistant || newVersion) )
[self rescanItems:self];

if (newVersion && !DEBUG)
#ifndef DEBUG
if (newVersion)
[[QSUpdateController sharedInstance] forceStartupCheck];
#endif

[[QSUpdateController sharedInstance] setUpdateTimer];

Expand Down
6 changes: 4 additions & 2 deletions Quicksilver/Code-App/QSHelpersPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ - (NSMenu *)menuForTable:(NSString *)table includeDefault:(BOOL)includeDefault {
NSDictionary *mediators = [QSReg tableNamed:table];
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"popUp"];
if (![mediators count]) {
if (!DEBUG) {

#ifndef DEBUG
[menu release];
return nil;
}
#endif

[menu addItemWithTitle:@"None Available" action:nil keyEquivalent:@""];
return [menu autorelease];
}
Expand Down
4 changes: 3 additions & 1 deletion Quicksilver/Code-App/QSTriggersPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject {

- (IBAction)outlineClicked:(id)sender {
if( [triggerTable clickedColumn] == -1 ) {
if (DEBUG) NSLog(@"%@ with column == -1", NSStringFromSelector(_cmd));
#ifdef DEBUG
NSLog(@"%@ with column == -1", NSStringFromSelector(_cmd));
#endif
return;
}
NSTableColumn *col = [[triggerTable tableColumns] objectAtIndex:[triggerTable clickedColumn]];
Expand Down
Loading