Correct __bridge_retained and __bridge_transfer casts using ARC

This commit is contained in:
Dmitry Serov 2017-08-01 17:40:39 +07:00
parent 68a1960be8
commit 3ae8f41f71
4 changed files with 10 additions and 9 deletions

View File

@ -148,7 +148,7 @@ typedef enum
- (void) removeTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData;
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode
contextInfo: (NSDictionary *) dict;
contextInfo: (void *) contextInfo;
- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData;
- (void) removeNoDelete: (id) sender;
- (void) removeDeleteData: (id) sender;

View File

@ -1448,7 +1448,7 @@ static void removeKeRangerRansomware()
NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge void *)(dict), @"%@", message);
nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge_retained void *)(dict), @"%@", message);
return;
}
}
@ -1456,8 +1456,9 @@ static void removeKeRangerRansomware()
[self confirmRemoveTorrents: torrents deleteData: deleteData];
}
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (NSDictionary *) dict
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
NSDictionary * dict = (__bridge_transfer NSDictionary *)contextInfo;
NSArray * torrents = dict[@"Torrents"];
if (returnCode == NSAlertDefaultReturn)
[self confirmRemoveTorrents: torrents deleteData: [dict[@"DeleteData"] boolValue]];

View File

@ -44,7 +44,7 @@ typedef void (^CompletionBlock)(BOOL);
renamer.torrent = torrent;
renamer.completionHandler = completionHandler;
[NSApp beginSheet: [renamer window] modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: (__bridge void *)(renamer)];
[NSApp beginSheet: [renamer window] modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: (__bridge_retained void *)(renamer)];
}
+ (void) presentSheetForFileListNode: (FileListNode *) node modalForWindow: (NSWindow *) window completionHandler: (void (^)(BOOL didRename)) completionHandler
@ -58,12 +58,12 @@ typedef void (^CompletionBlock)(BOOL);
renamer.node = node;
renamer.completionHandler = completionHandler;
[NSApp beginSheet: [renamer window] modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: (__bridge void *)(renamer)];
[NSApp beginSheet: [renamer window] modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: (__bridge_retained void *)(renamer)];
}
+ (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
FileRenameSheetController * renamer = (__bridge FileRenameSheetController *)(contextInfo);
FileRenameSheetController * renamer = (__bridge_transfer FileRenameSheetController *)(contextInfo);
NSParameterAssert([renamer isKindOfClass:[FileRenameSheetController class]]);
renamer.completionHandler(returnCode == NSOKButton);

View File

@ -104,7 +104,7 @@ void renameCallback(tr_torrent * torrent, const char * oldPathCharString, const
NSString * newName = @(newNameCharString);
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary * contextDict = (__bridge NSDictionary *)contextInfo;
NSDictionary * contextDict = (__bridge_transfer NSDictionary *)contextInfo;
Torrent * torrentObject = contextDict[@"Torrent"];
[torrentObject renameFinished: error == 0 nodes: contextDict[@"Nodes"] completionHandler: contextDict[@"CompletionHandler"] oldPath: oldPath newName: newName];
});
@ -839,7 +839,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
NSDictionary * contextInfo = @{ @"Torrent" : self, @"CompletionHandler" : [completionHandler copy] };
tr_torrentRenamePath(fHandle, fInfo->name, [newName UTF8String], renameCallback, (__bridge void *)(contextInfo));
tr_torrentRenamePath(fHandle, fInfo->name, [newName UTF8String], renameCallback, (__bridge_retained void *)(contextInfo));
}
- (void) renameFileNode: (FileListNode *) node withName: (NSString *) newName completionHandler: (void (^)(BOOL didRename)) completionHandler
@ -851,7 +851,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
NSDictionary * contextInfo = @{ @"Torrent" : self, @"Nodes" : @[ node ], @"CompletionHandler" : [completionHandler copy] };
NSString * oldPath = [[node path] stringByAppendingPathComponent: [node name]];
tr_torrentRenamePath(fHandle, [oldPath UTF8String], [newName UTF8String], renameCallback, (__bridge void *)(contextInfo));
tr_torrentRenamePath(fHandle, [oldPath UTF8String], [newName UTF8String], renameCallback, (__bridge_retained void *)(contextInfo));
}
- (CGFloat) progress