diff --git a/ChangeLog b/ChangeLog index a05ef4c31..5fd82c187 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-08 Jonathan Gillaspie + + * Source/GSToolTips.m: Prevent Windows API callback from crashing when displaying tooltips. + 2010-04-07 Fred Kiefer * Headers/Cocoa/Cocoa.h: One more forgotten header file changed diff --git a/Source/GSToolTips.m b/Source/GSToolTips.m index 9d38da6e0..7ac238eb1 100644 --- a/Source/GSToolTips.m +++ b/Source/GSToolTips.m @@ -119,6 +119,28 @@ } @end +@interface GSTTPanel : NSPanel +// Tooltip panel that will not try to become main or key +- (BOOL) canBecomeKeyWindow; +- (BOOL) canBecomeMainWindow; + +@end + +@implementation GSTTPanel + +- (BOOL) canBecomeKeyWindow +{ + return NO; +} + +- (BOOL) canBecomeMainWindow +{ + return NO; +} + +@end + + @interface GSToolTips (Private) - (void) _drawText: (NSAttributedString *)text; - (void) _endDisplay; @@ -137,7 +159,8 @@ typedef NSView* NSViewPtr; static NSMapTable *viewsMap = 0; static NSTimer *timer = nil; static GSToolTips *timedObject = nil; -static NSPanel *window = nil; +static GSTTPanel *window = nil; +static BOOL isOpening = NO; // Prevent Windows callback API from attempting to dismiss tooltip as its in the process of appearing static NSSize offset; static BOOL restoreMouseMoved; @@ -462,6 +485,8 @@ static BOOL restoreMouseMoved; - (void) _endDisplay { + if (isOpening) + return; if ([NSWindow _toolTipVisible] == self) { [NSWindow _setToolTipVisible: nil]; @@ -573,7 +598,8 @@ static BOOL restoreMouseMoved; offset.height = rect.origin.y - mouseLocation.y; offset.width = rect.origin.x - mouseLocation.x; - window = [[NSPanel alloc] initWithContentRect: rect + isOpening = YES; + window = [[GSTTPanel alloc] initWithContentRect: rect styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: YES]; @@ -591,6 +617,7 @@ static BOOL restoreMouseMoved; [window display]; [self _drawText: toolTipText]; [window flushWindow]; + isOpening = NO; RELEASE(toolTipText); }