mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixed bootstrap problem where NSBundle +initialize would use NSUserDefaults +standardDefaults to create the _gnustep_bundle, and NSUserDefaults +standardDefaults would use NSBundle's _gnustep_bundle to lookup resources
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24869 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
97b76e81d1
commit
5fa74f7f71
3 changed files with 49 additions and 9 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-03-14 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* Source/NSUserDefaults.m ([+standardUserDefaults]): Manually
|
||||
lookup gnustep-base language resources without using NSBundle to
|
||||
break the bootstrap chicken-and-egg problem between NSBundle and
|
||||
NSUserDefaults.
|
||||
|
||||
2007-03-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSXML.m: Fix memory leak caused by url handle
|
||||
|
|
|
@ -2196,6 +2196,10 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
|||
+ (NSBundle *) bundleForLibrary: (NSString *)libraryName
|
||||
version: (NSString *)interfaceVersion
|
||||
{
|
||||
/* Important: if you change this code, make sure to also
|
||||
* change NSUserDefault's manual gnustep-base resource
|
||||
* lookup to match.
|
||||
*/
|
||||
NSArray *paths;
|
||||
NSEnumerator *enumerator;
|
||||
NSString *path;
|
||||
|
|
|
@ -498,15 +498,44 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
enumerator = [uL objectEnumerator];
|
||||
while ((lang = [enumerator nextObject]))
|
||||
{
|
||||
NSString *path;
|
||||
NSDictionary *dict;
|
||||
NSBundle *gbundle;
|
||||
|
||||
gbundle = [NSBundle bundleForClass: [NSObject class]];
|
||||
path = [gbundle pathForResource: lang
|
||||
ofType: nil
|
||||
inDirectory: @"Languages"];
|
||||
dict = nil;
|
||||
/* We lookup gnustep-base resources manually here to prevent
|
||||
* bootstrap problems. NSBundle's lookup routines depend on
|
||||
* having NSUserDefaults already bootstrapped, but we're still
|
||||
* bootstrapping here! So we can't really use NSBundle without
|
||||
* incurring massive bootstrap complications (btw, most of the
|
||||
* times we're here as a consequence of [NSBundle +initialize]
|
||||
* creating the gnustep-base bundle! So trying to use the
|
||||
* gnustep-base bundle here wouldn't really work.).
|
||||
*/
|
||||
/*
|
||||
* We are looking for:
|
||||
*
|
||||
* GNUSTEP_LIBRARY/Libraries/gnustep-base/Versions/<interfaceVersion>/Resources/Languages/<language>
|
||||
*/
|
||||
NSDictionary *dict = nil;
|
||||
NSString *path = nil;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSString *tail = [[[[[[@"Libraries" stringByAppendingPathComponent: @"gnustep-base"]
|
||||
stringByAppendingPathComponent: @"Versions"]
|
||||
stringByAppendingPathComponent: OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)]
|
||||
stringByAppendingPathComponent: @"Resources"]
|
||||
stringByAppendingPathComponent: @"Languages"]
|
||||
stringByAppendingPathComponent: lang];
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
enumerator = [paths objectEnumerator];
|
||||
while ((path = [enumerator nextObject]) != nil)
|
||||
{
|
||||
BOOL isDir;
|
||||
path = [path stringByAppendingPathComponent: tail];
|
||||
|
||||
if ([fm fileExistsAtPath: path isDirectory: &isDir])
|
||||
{
|
||||
/* Path found! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (path != nil)
|
||||
{
|
||||
dict = [NSDictionary dictionaryWithContentsOfFile: path];
|
||||
|
|
Loading…
Reference in a new issue