git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4225 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-05-07 13:51:37 +00:00
parent a1cff1dad7
commit 0e724b3880
2 changed files with 18 additions and 17 deletions

View file

@ -1,6 +1,8 @@
Fri May 7 13:46:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
Fri May 7 15:12:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* 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 <richard@brainstorm.co.uk>

View file

@ -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;