mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
f5bb569071
commit
66ad962d5d
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>
|
2007-03-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/Additions/GSXML.m: Fix memory leak caused by url handle
|
* 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
|
+ (NSBundle *) bundleForLibrary: (NSString *)libraryName
|
||||||
version: (NSString *)interfaceVersion
|
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;
|
NSArray *paths;
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
|
|
|
@ -498,15 +498,44 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
||||||
enumerator = [uL objectEnumerator];
|
enumerator = [uL objectEnumerator];
|
||||||
while ((lang = [enumerator nextObject]))
|
while ((lang = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
NSString *path;
|
/* We lookup gnustep-base resources manually here to prevent
|
||||||
NSDictionary *dict;
|
* bootstrap problems. NSBundle's lookup routines depend on
|
||||||
NSBundle *gbundle;
|
* having NSUserDefaults already bootstrapped, but we're still
|
||||||
|
* bootstrapping here! So we can't really use NSBundle without
|
||||||
gbundle = [NSBundle bundleForClass: [NSObject class]];
|
* incurring massive bootstrap complications (btw, most of the
|
||||||
path = [gbundle pathForResource: lang
|
* times we're here as a consequence of [NSBundle +initialize]
|
||||||
ofType: nil
|
* creating the gnustep-base bundle! So trying to use the
|
||||||
inDirectory: @"Languages"];
|
* gnustep-base bundle here wouldn't really work.).
|
||||||
dict = nil;
|
*/
|
||||||
|
/*
|
||||||
|
* 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)
|
if (path != nil)
|
||||||
{
|
{
|
||||||
dict = [NSDictionary dictionaryWithContentsOfFile: path];
|
dict = [NSDictionary dictionaryWithContentsOfFile: path];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue