From 4dbc3bd335825543b3c114b73dde0535ec8fd02e Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 7 May 1999 13:51:37 +0000 Subject: [PATCH] Tidyup git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4225 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++-- Source/NSBundle.m | 29 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index e61bc758b..07c08ecdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ -Fri May 7 13:46:00 1999 Richard Frith-Macdonald +Fri May 7 15:12:00 1999 Richard Frith-Macdonald - * Source/NSBundle.m: Modified ([-release]) to avoid unnecessary work. + * Source/NSBundle.m: Modified ([-release]) to avoid unnecessary work + and to refrain from caching bundles unless they have loaded code + (or are the main bundle or the gnustep bundle). Thu May 6 21:00:00 1999 Richard Frith-Macdonald diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 3bb70c122..3d48a0521 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -453,25 +453,22 @@ _bundle_load_callback(Class theClass, Category *theCategory) /* Some bundles should not be dealloced, such as the main bundle. So we keep track of our own retain count to avoid this. Currently, the objc runtime can't unload modules, so we actually - avoid deallocating any bundle */ + avoid deallocating any bundle with code loaded */ - (oneway void) release { - if ([self retainCount] == 0) + if (_codeLoaded == YES || self == _mainBundle || self == _gnustep_bundle) { - if (self == NSMapGet(_releasedBundles, _path)) + if ([self retainCount] == 0) { - [NSException raise: NSGenericException - format: @"Bundle for path %@ released too many times", _path]; - } - - /* Cache all bundles */ - if (_bundleType == NSBUNDLE_APPLICATION - || _bundleType == NSBUNDLE_LIBRARY - || _bundleType == NSBUNDLE_BUNDLE) - { - NSMapRemove(_bundles, _path); - NSMapInsert(_releasedBundles, _path, self); - return; + if (self == NSMapGet(_releasedBundles, _path)) + { + [NSException raise: NSGenericException + format: @"Bundle for path %@ released too many times", _path]; + } + + NSMapRemove(_bundles, _path); + NSMapInsert(_releasedBundles, _path, self); + return; } } [super release]; @@ -572,11 +569,13 @@ _bundle_load_callback(Class theClass, Category *theCategory) } _codeLoaded = YES; _loadingBundle = nil; + [load_lock unlock]; [[NSNotificationCenter defaultCenter] postNotificationName: NSBundleDidLoadNotification object: self userInfo: [NSDictionary dictionaryWithObjects: &_bundleClasses forKeys: &NSLoadedClasses count: 1]]; + return YES; } [load_lock unlock]; return YES;