diff --git a/ChangeLog b/ChangeLog index e485b13d1..c66dfe9ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-08-20 14:36 Alexander Malmberg + + * Source/GSFontInfo.m (+sharedEnumerator, + +fontInfoForFontName:matrix:screenFont:): Assert that the backend + classes have been set. + + * Source/NSBrowser.m (+initialize, -initWithFrame:): Don't create + the shared title cell in +initialize. Creating the cell requires + that the backend has been set up (by creating the shared application + object). We can't assume that this has been done before +initialize + is called. + + * Source/NSTextView.m (+initialize, -initWithFrame:textContainer:): + Don't register for services in +initialize for the same reason: the + shared application object might not have been created yet (also, note + that calling +sharedApplication is unsafe; it will create a shared + application object, but in some cases of the wrong class, which would + lead to confusing errors later). + 2003-08-20 14:08 Alexander Malmberg Clean up code to remove warnings issued by (what will become) diff --git a/Source/GSFontInfo.m b/Source/GSFontInfo.m index 13a8ee9b9..be19606f6 100644 --- a/Source/GSFontInfo.m +++ b/Source/GSFontInfo.m @@ -33,6 +33,7 @@ #include #include #include +#include static Class fontEnumeratorClass = Nil; static Class fontInfoClass = Nil; @@ -63,6 +64,10 @@ static GSFontEnumerator *sharedEnumerator = nil; + (GSFontEnumerator*) sharedEnumerator { + NSAssert(fontEnumeratorClass, + @"Called with fontEnumeratorClass unset." + @" The shared NSApplication instance must be created before methods that" + @" need the backend may be called."); if (!sharedEnumerator) sharedEnumerator = [[fontEnumeratorClass alloc] init]; return sharedEnumerator; @@ -125,6 +130,10 @@ static GSFontEnumerator *sharedEnumerator = nil; matrix: (const float *)fmatrix screenFont: (BOOL)screenFont; { + NSAssert(fontInfoClass, + @"Called with fontInfoClass unset." + @" The shared NSApplication instance must be created before methods that" + @" need the backend may be called."); return AUTORELEASE([[fontInfoClass alloc] initWithFontName: nfontName matrix: fmatrix screenFont: screenFont]); diff --git a/Source/NSBrowser.m b/Source/NSBrowser.m index 8f8c78924..c166831b5 100644 --- a/Source/NSBrowser.m +++ b/Source/NSBrowser.m @@ -1887,7 +1887,6 @@ static NSTextFieldCell *titleCell; // Initial version [self setVersion: 1]; scrollerWidth = [NSScroller scrollerWidth]; - titleCell = [GSBrowserTitleCell new]; } } @@ -1901,6 +1900,12 @@ static NSTextFieldCell *titleCell; NSSize bs; //NSScroller *hs; + /* Created the shared titleCell if it hasn't been created already. */ + if (!titleCell) + { + titleCell = [GSBrowserTitleCell new]; + } + self = [super initWithFrame: rect]; // Class setting diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 5996ed51a..1dab826dd 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -375,19 +375,23 @@ this happens when layout has been invalidated, and when we are resized. { [self setVersion: currentVersion]; notificationCenter = [NSNotificationCenter defaultCenter]; - [self registerForServices]; } } +static BOOL did_register_for_services; + +(void) registerForServices { NSArray *types; - + + did_register_for_services = YES; + types = [NSArray arrayWithObjects: NSStringPboardType, NSRTFPboardType, NSRTFDPboardType, nil]; - - [[NSApplication sharedApplication] registerServicesMenuSendTypes: types - returnTypes: types]; + + NSAssert(NSApp, @"Called before the shared application object was created."); + [NSApp registerServicesMenuSendTypes: types + returnTypes: types]; } +(NSDictionary *) defaultTypingAttributes @@ -474,6 +478,9 @@ If a text view is added to an empty text network, it keeps its attributes. if (!self) return nil; + if (!did_register_for_services) + [isa registerForServices]; + _minSize = NSMakeSize(0, 0); _maxSize = NSMakeSize(HUGE,HUGE); _textContainerInset = NSMakeSize(2, 0);