Skip to content

Commit

Permalink
Add some debug code for another crash that has been happening lately
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Oct 2, 2015
1 parent 9233309 commit f38ffcb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ - (id)queryString:(NSString *)theQueryString usingEncoding:(NSStringEncoding)the
theSqlstate = [self _stringForCString:mysql_sqlstate(mySQLConnection)];

// Prevent retries if the query was cancelled or not a connection error
if (lastQueryWasCancelled || ![SPMySQLConnection isErrorIDConnectionError:mysql_errno(mySQLConnection)]) {
if (lastQueryWasCancelled || ![SPMySQLConnection isErrorIDConnectionError:theErrorID]) {
break;
}
}
Expand Down
38 changes: 37 additions & 1 deletion Source/SPObjectAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ - (void)sp_addObserver:(id)notificationObserver selector:(SEL)notificationSelect
if([notificationObserver isKindOfClass:[NSView class]]) {
[val appendFormat:@" view info: id=%@, tag=%ld\n",[(NSView *)notificationObserver identifier], [(NSView *)notificationObserver tag]];
}
[val appendFormat:@"\nbacktrace:\n%@\n\n",[NSThread callStackSymbols]];
[val appendFormat:@"\nregistration backtrace:\n%@\n\n",[NSThread callStackSymbols]];

[gScrollViewListeners setObject:val forKey:key];
}
Expand Down Expand Up @@ -185,4 +185,40 @@ - (void)sp_dealloc
}


@end

#pragma mark -

@interface NSAlert (ApplePrivate)

- (IBAction)buttonPressed:(id)sender;

@end

@implementation NSAlert (SPAlertDebug)

+ (void)load
{
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
Class alertClass = [self class];

SEL orig = @selector(buttonPressed:);
SEL exch = @selector(sp_buttonPressed:);

Method origM = class_getInstanceMethod(alertClass, orig);
Method exchM = class_getInstanceMethod(alertClass, exch);

method_exchangeImplementations(origM, exchM);
});
}

- (IBAction)sp_buttonPressed:(id)obj
{
NSLog(@"%s of %@ title=\n%@\ntext=\n%@",__func__,self,[self messageText],[self informativeText]);

[self sp_buttonPressed:obj];
}

@end
2 changes: 1 addition & 1 deletion Source/SPTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (void) awakeFromNib

if ([NSTableView instancesRespondToSelector:@selector(awakeFromNib)]) {
[super awakeFromNib];
}
}
}

#pragma mark -
Expand Down

0 comments on commit f38ffcb

Please sign in to comment.