mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 02:20:48 +00:00
fix leak
This commit is contained in:
parent
a021005af7
commit
b847a444b3
1 changed files with 85 additions and 66 deletions
|
@ -40,7 +40,7 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
- (instancetype) init
|
- (instancetype) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
_url = nil;
|
_url = nil;
|
||||||
_isRead = NO;
|
_isRead = NO;
|
||||||
|
@ -53,20 +53,22 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
options: (NSFileCoordinatorReadingOptions)options
|
options: (NSFileCoordinatorReadingOptions)options
|
||||||
{
|
{
|
||||||
NSFileAccessIntent *result = [[self alloc] init];
|
NSFileAccessIntent *result = [[self alloc] init];
|
||||||
|
|
||||||
ASSIGNCOPY(result->_url, url);
|
ASSIGNCOPY(result->_url, url);
|
||||||
result->_options = options;
|
result->_options = options;
|
||||||
result->_isRead = YES;
|
result->_isRead = YES;
|
||||||
return result;
|
return AUTORELEASE(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype) writingIntentWithURL: (NSURL *)url
|
+ (instancetype) writingIntentWithURL: (NSURL *)url
|
||||||
options: (NSFileCoordinatorWritingOptions)options
|
options: (NSFileCoordinatorWritingOptions)options
|
||||||
{
|
{
|
||||||
NSFileAccessIntent *result = [[self alloc] init];
|
NSFileAccessIntent *result = [[self alloc] init];
|
||||||
|
|
||||||
ASSIGNCOPY(result->_url, url);
|
ASSIGNCOPY(result->_url, url);
|
||||||
result->_options = options;
|
result->_options = options;
|
||||||
result->_isRead = NO;
|
result->_isRead = NO;
|
||||||
return result;
|
return AUTORELEASE(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSURL *) URL
|
- (NSURL *) URL
|
||||||
|
@ -79,7 +81,7 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if(self == [NSFileCoordinator class])
|
if (self == [NSFileCoordinator class])
|
||||||
{
|
{
|
||||||
__presenters = [[NSMutableArray alloc] init];
|
__presenters = [[NSMutableArray alloc] init];
|
||||||
__presenterMap = [[NSMutableDictionary alloc] init];
|
__presenterMap = [[NSMutableDictionary alloc] init];
|
||||||
|
@ -109,7 +111,7 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
- (instancetype) init
|
- (instancetype) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
NSString *p = nil;
|
NSString *p = nil;
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
{
|
{
|
||||||
NSEnumerator *en = [__presenters objectEnumerator];
|
NSEnumerator *en = [__presenters objectEnumerator];
|
||||||
id obj = nil;
|
id obj = nil;
|
||||||
while((obj = [en nextObject]) != nil)
|
while ((obj = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> o = (id<NSFilePresenter>)obj;
|
id<NSFilePresenter> o = (id<NSFilePresenter>)obj;
|
||||||
NSOperationQueue *q = [o presentedItemOperationQueue];
|
NSOperationQueue *q = [o presentedItemOperationQueue];
|
||||||
|
@ -151,7 +153,7 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
NSEnumerator *en = [intents objectEnumerator];
|
NSEnumerator *en = [intents objectEnumerator];
|
||||||
id obj = nil;
|
id obj = nil;
|
||||||
|
|
||||||
while((obj = [en nextObject]) != nil)
|
while ((obj = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSBlockOperation *op;
|
NSBlockOperation *op;
|
||||||
|
|
||||||
|
@ -161,127 +163,144 @@ static NSMutableDictionary *__presenterIdDict = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)coordinateReadingItemAtURL: (NSURL *)readingURL
|
- (void) coordinateReadingItemAtURL: (NSURL *)readingURL
|
||||||
options: (NSFileCoordinatorReadingOptions)readingOptions
|
options: (NSFileCoordinatorReadingOptions)readingOptions
|
||||||
writingItemAtURL: (NSURL *)writingURL
|
writingItemAtURL: (NSURL *)writingURL
|
||||||
options: (NSFileCoordinatorWritingOptions)writingOptions
|
options: (NSFileCoordinatorWritingOptions)writingOptions
|
||||||
error: (NSError **)outError
|
error: (NSError **)outError
|
||||||
byAccessor: (GSNoEscapeReadWriteHandler)readerWriter
|
byAccessor: (GSNoEscapeReadWriteHandler)readerWriter
|
||||||
{
|
{
|
||||||
if(readingOptions == 0L)
|
if (readingOptions == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: readingURL];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: readingURL];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
|
||||||
|
if ([p respondsToSelector:
|
||||||
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
{
|
{
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(writingOptions == 0L)
|
if (writingOptions == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: writingURL];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: writingURL];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
|
||||||
|
if ([p respondsToSelector:
|
||||||
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
{
|
{
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CALL_BLOCK(readerWriter, readingURL, writingURL);
|
CALL_BLOCK(readerWriter, readingURL, writingURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)coordinateReadingItemAtURL: (NSURL *)url
|
- (void) coordinateReadingItemAtURL: (NSURL *)url
|
||||||
options: (NSFileCoordinatorReadingOptions)options
|
options: (NSFileCoordinatorReadingOptions)options
|
||||||
error: (NSError **)outError
|
error: (NSError **)outError
|
||||||
byAccessor: (GSNoEscapeNewURLHandler)reader
|
byAccessor: (GSNoEscapeNewURLHandler)reader
|
||||||
{
|
{
|
||||||
if(options == 0L)
|
if (options == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
if ([p respondsToSelector:
|
||||||
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
{
|
{
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CALL_BLOCK(reader, url);
|
CALL_BLOCK(reader, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)coordinateWritingItemAtURL: (NSURL *)url
|
- (void) coordinateWritingItemAtURL: (NSURL *)url
|
||||||
options: (NSFileCoordinatorWritingOptions)options
|
options: (NSFileCoordinatorWritingOptions)options
|
||||||
error: (NSError **)outError
|
error: (NSError **)outError
|
||||||
byAccessor: (GSNoEscapeNewURLHandler)writer
|
byAccessor: (GSNoEscapeNewURLHandler)writer
|
||||||
{
|
{
|
||||||
if(options == 0L)
|
if (options == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
if ([p respondsToSelector:
|
||||||
{
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
{
|
||||||
}
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CALL_BLOCK(writer, url);
|
CALL_BLOCK(writer, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)coordinateWritingItemAtURL: (NSURL *)url1
|
- (void) coordinateWritingItemAtURL: (NSURL *)url1
|
||||||
options: (NSFileCoordinatorWritingOptions)options1
|
options: (NSFileCoordinatorWritingOptions)options1
|
||||||
writingItemAtURL: (NSURL *)url2
|
writingItemAtURL: (NSURL *)url2
|
||||||
options: (NSFileCoordinatorWritingOptions)options2
|
options: (NSFileCoordinatorWritingOptions)options2
|
||||||
error: (NSError **)outError
|
error: (NSError **)outError
|
||||||
byAccessor: (GSDualWriteURLCallbackHandler)writer
|
byAccessor: (GSDualWriteURLCallbackHandler)writer
|
||||||
{
|
{
|
||||||
if(options1 == 0L)
|
if (options1 == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: url1];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: url1];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
|
||||||
{
|
if ([p respondsToSelector:
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
}
|
{
|
||||||
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options2 == 0L)
|
if (options2 == 0L)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: url2];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: url2];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
|
||||||
{
|
if ([p respondsToSelector:
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
}
|
{
|
||||||
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CALL_BLOCK(writer, url1, url2);
|
CALL_BLOCK(writer, url1, url2);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)itemAtURL: (NSURL *)oldURL didMoveToURL: (NSURL *)newURL
|
- (void) itemAtURL: (NSURL *)oldURL didMoveToURL: (NSURL *)newURL
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> presenter = [__presenterMap objectForKey: oldURL];
|
id<NSFilePresenter> presenter = [__presenterMap objectForKey: oldURL];
|
||||||
|
|
||||||
[presenter presentedItemDidMoveToURL: newURL];
|
[presenter presentedItemDidMoveToURL: newURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)itemAtURL: (NSURL *)oldURL willMoveToURL: (NSURL *)newURL
|
- (void) itemAtURL: (NSURL *)oldURL willMoveToURL: (NSURL *)newURL
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> presenter = [__presenterMap objectForKey: oldURL];
|
id<NSFilePresenter> presenter = [__presenterMap objectForKey: oldURL];
|
||||||
|
|
||||||
[presenter presentedItemDidChange]; // there is no "Will" method for this, so I am a bit perplexed.
|
[presenter presentedItemDidChange]; // there is no "Will" method for this, so I am a bit perplexed.
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)itemAtURL: (NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes
|
- (void) itemAtURL: (NSURL *)url
|
||||||
|
didChangeUbiquityAttributes: (NSSet *)attributes
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> presenter = [__presenterMap objectForKey: url];
|
id<NSFilePresenter> presenter = [__presenterMap objectForKey: url];
|
||||||
|
|
||||||
[presenter presentedItemDidChangeUbiquityAttributes: attributes];
|
[presenter presentedItemDidChangeUbiquityAttributes: attributes];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prepareForReadingItemsAtURLs: (NSArray *)readingURLs
|
- (void) prepareForReadingItemsAtURLs: (NSArray *)readingURLs
|
||||||
options: (NSFileCoordinatorReadingOptions)readingOptions
|
options: (NSFileCoordinatorReadingOptions)readingOptions
|
||||||
writingItemsAtURLs: (NSArray *)writingURLs
|
writingItemsAtURLs: (NSArray *)writingURLs
|
||||||
options: (NSFileCoordinatorWritingOptions)writingOptions
|
options: (NSFileCoordinatorWritingOptions)writingOptions
|
||||||
error: (NSError **)outError
|
error: (NSError **)outError
|
||||||
byAccessor: (GSBatchAccessorCompositeBlock)batchAccessor
|
byAccessor: (GSBatchAccessorCompositeBlock)batchAccessor
|
||||||
{
|
{
|
||||||
if(readingOptions == 0L)
|
if (readingOptions == 0L)
|
||||||
{
|
{
|
||||||
NSEnumerator *en = [readingURLs objectEnumerator];
|
NSEnumerator *en = [readingURLs objectEnumerator];
|
||||||
NSURL *aurl = nil;
|
NSURL *aurl = nil;
|
||||||
while((aurl = [en nextObject]) != nil)
|
|
||||||
|
while ((aurl = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
id<NSFilePresenter> p = [__presenterMap objectForKey: aurl];
|
id<NSFilePresenter> p = [__presenterMap objectForKey: aurl];
|
||||||
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
|
|
||||||
|
if ([p respondsToSelector:
|
||||||
|
@selector(savePresentedItemChangesWithCompletionHandler:)])
|
||||||
{
|
{
|
||||||
[p savePresentedItemChangesWithCompletionHandler:NULL];
|
[p savePresentedItemChangesWithCompletionHandler: NULL];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue