diff --git a/ChangeLog b/ChangeLog index 8b7d6c04b..59bfbe419 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Apr 19 14:54:00 1999 Richard Frith-Macdonald + + * Source/NSApplication.m: Link in dummy function to ensure that + NSStringDrawing catagories are linked when using static libs. + * Source/NSStringDrawing.m: Add dummy function to force link. + * Source/NSEvent.m: Faster thread access. + * Source/NSGraphicsContext.m: ditto. + Sun Apr 18 6:30:00 1999 Richard Frith-Macdonald Added all improvements from mgstep. diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 4481506c2..4ae584c70 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -107,13 +107,24 @@ NSApplication *NSApp = nil; { if (self == [NSApplication class]) { + /* + * Dummy functions to fool linker into linking files that contain + * only catagories - static libraries seem to have problems here. + */ + extern void GSStringDrawingDummyFunction(); + + GSStringDrawingDummyFunction(); + NSDebugLog(@"Initialize NSApplication class\n"); - // Initial version - [self setVersion:1]; - // So the application knows - gnustep_gui_app_is_in_dealloc = NO; // it's within dealloc and - } // can prevent -release -} // loops. + [self setVersion: 1]; + + /* + * So the application knows it's within dealloc and + * can prevent -release loops + */ + gnustep_gui_app_is_in_dealloc = NO; + } +} + (NSApplication *)sharedApplication { // If the global application does diff --git a/Source/NSEvent.m b/Source/NSEvent.m index de9cf90d4..0bf662f6b 100644 --- a/Source/NSEvent.m +++ b/Source/NSEvent.m @@ -43,6 +43,14 @@ #include #include +/* + * gstep-base has a faster mechanism to get the current thread. + */ +#ifndef GNUSTEP_BASE_LIBRARY +#define GSCurrentThread() [NSThread currentThread] +#define GSCurrentThreadDictionary() [[NSThread currentThread] threadDictionary] +#endif + @implementation NSEvent // Class variables @@ -192,14 +200,14 @@ static NSString *timerKey = @"NSEventTimersKey"; withPeriod: (NSTimeInterval)periodSeconds { NSTimer *timer; - NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; + NSMutableDictionary *dict = GSCurrentThreadDictionary(); NSDebugLog (@"startPeriodicEventsAfterDelay: withPeriod: "); if ([dict objectForKey: timerKey]) [NSException raise: NSInternalInconsistencyException format: @"Periodic events are already being generated for " - @"this thread %x", [NSThread currentThread]]; + @"this thread %x", GSCurrentThread()]; // If the delay time is 0 then register a timer immediately. Otherwise // register a timer with no repeat that when fired registers the real timer @@ -243,7 +251,7 @@ static NSString *timerKey = @"NSEventTimersKey"; + (void) _registerRealTimer: (NSTimer*)timer { NSTimer* realTimer; - NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; + NSMutableDictionary *dict = GSCurrentThreadDictionary(); NSDebugLog (@"_registerRealTimer: "); @@ -260,7 +268,7 @@ static NSString *timerKey = @"NSEventTimersKey"; + (void) stopPeriodicEvents { NSTimer* timer; - NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; + NSMutableDictionary *dict = GSCurrentThreadDictionary(); NSDebugLog (@"stopPeriodicEvents"); timer = [dict objectForKey: timerKey]; diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index 6970dbeb4..3a50236cf 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -95,16 +95,23 @@ static NSString *NSGraphicsContextThredKey = @"NSGraphicsContextThredKey"; return ctxt; } +/* + * gstep-base has a faster mechanism to get the current thread. + */ +#ifndef GNUSTEP_BASE_LIBRARY +#define GSCurrentThreadDictionary() [[NSThread currentThread] threadDictionary] +#endif + + (void) setCurrentContext: (NSGraphicsContext *)context { - NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; + NSMutableDictionary *dict = GSCurrentThreadDictionary(); [dict setObject: context forKey: NSGraphicsContextThredKey]; } + (NSGraphicsContext *) currentContext { - NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; + NSMutableDictionary *dict = GSCurrentThreadDictionary(); return (NSGraphicsContext*) [dict objectForKey: NSGraphicsContextThredKey]; } diff --git a/Source/NSStringDrawing.m b/Source/NSStringDrawing.m index 27904ac42..82cbf6f18 100644 --- a/Source/NSStringDrawing.m +++ b/Source/NSStringDrawing.m @@ -31,6 +31,14 @@ #include #include +/* + * A function called by NSApplication to ensure that this file is linked + * when it should be. + */ +void +GSStringDrawingDummyFunction() +{ +} static NSCharacterSet *whitespace; static NSCharacterSet *newlines;