diff --git a/ChangeLog b/ChangeLog index 9e8844e54..a5ee3ab2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-05-12 Richard Frith-Macdonald + + * Source/NSURL.m: ([-loadResourceDataNotifyingClient:usingCache:]) + used cached information if requested. Always load using a cached + handle so that results will be available to later calls. + Addresses bug #8901 + 2004-05-09 David Ayers * Headers/Additions/GNUstepBase/GSObjCRuntime.h diff --git a/Source/NSURL.m b/Source/NSURL.m index f0cf94866..da8b32bf2 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -1132,25 +1132,44 @@ static unsigned urlAlign; - (void) loadResourceDataNotifyingClient: (id)client usingCache: (BOOL)shouldUseCache { - NSURLHandle *handle = [self URLHandleUsingCache: shouldUseCache]; + NSURLHandle *handle = [self URLHandleUsingCache: YES]; + NSData *d; - if (client != nil) + if (shouldUseCache == YES && (d = [handle availableResourceData]) != nil) { - [clientsLock lock]; - if (_clients == 0) + /* + * We already have cached data we should use. + */ + if ([client respondsToSelector: + @selector(URL:resourceDataDidBecomeAvailable:)]) { - _clients = NSCreateMapTable (NSObjectMapKeyCallBacks, - NSNonRetainedObjectMapValueCallBacks, 0); + [client URL: self resourceDataDidBecomeAvailable: d]; + } + if ([client respondsToSelector: @selector(URLResourceDidFinishLoading:)]) + { + [client URLResourceDidFinishLoading: self]; } - NSMapInsert((NSMapTable*)_clients, (void*)handle, (void*)client); - [clientsLock unlock]; - [handle addClient: self]; } + else + { + if (client != nil) + { + [clientsLock lock]; + if (_clients == 0) + { + _clients = NSCreateMapTable (NSObjectMapKeyCallBacks, + NSNonRetainedObjectMapValueCallBacks, 0); + } + NSMapInsert((NSMapTable*)_clients, (void*)handle, (void*)client); + [clientsLock unlock]; + [handle addClient: self]; + } - /* - * Kick off the load process. - */ - [handle loadInBackground]; + /* + * Kick off the load process. + */ + [handle loadInBackground]; + } } /** @@ -1335,7 +1354,7 @@ static unsigned urlAlign; /** * Loads the resource data for the represented URL and returns the result. - * The shoulduseCache flag determines whether an existing cached NSURLHandle + * The shouldUseCache flag determines whether an existing cached NSURLHandle * can be used to provide the data. */ - (NSData*) resourceDataUsingCache: (BOOL)shouldUseCache