mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
Address deprecations with NSKeyedUnarchiver (#2973)
This commit is contained in:
@@ -3566,7 +3566,16 @@ static void removeKeRangerRansomware()
|
||||
NSPasteboard* pasteboard = info.draggingPasteboard;
|
||||
if ([pasteboard.types containsObject:TORRENT_TABLE_VIEW_DATA_TYPE])
|
||||
{
|
||||
NSIndexSet* indexes = [NSKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:TORRENT_TABLE_VIEW_DATA_TYPE]];
|
||||
NSIndexSet* indexes;
|
||||
if (@available(macOS 10.13, *))
|
||||
{
|
||||
indexes = [NSKeyedUnarchiver unarchivedObjectOfClass:NSIndexSet.class fromData:[pasteboard dataForType:TORRENT_TABLE_VIEW_DATA_TYPE]
|
||||
error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
indexes = [NSKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:TORRENT_TABLE_VIEW_DATA_TYPE]];
|
||||
}
|
||||
|
||||
//get the torrents to move
|
||||
NSMutableArray* movingTorrents = [NSMutableArray arrayWithCapacity:indexes.count];
|
||||
|
||||
@@ -40,7 +40,21 @@ GroupsController* fGroupsInstance = nil;
|
||||
NSData* data;
|
||||
if ((data = [NSUserDefaults.standardUserDefaults dataForKey:@"GroupDicts"]))
|
||||
{
|
||||
_fGroups = [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
if (@available(macOS 10.13, *))
|
||||
{
|
||||
_fGroups = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObjects:NSMutableArray.class,
|
||||
NSMutableDictionary.class,
|
||||
NSNumber.class,
|
||||
NSColor.class,
|
||||
NSString.class,
|
||||
nil]
|
||||
fromData:data
|
||||
error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
_fGroups = [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
}
|
||||
}
|
||||
else if ((data = [NSUserDefaults.standardUserDefaults dataForKey:@"Groups"])) //handle old groups
|
||||
{
|
||||
@@ -48,7 +62,7 @@ GroupsController* fGroupsInstance = nil;
|
||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"Groups"];
|
||||
[self saveGroups];
|
||||
}
|
||||
else
|
||||
if (_fGroups == nil)
|
||||
{
|
||||
//default groups
|
||||
NSMutableDictionary* red = [NSMutableDictionary
|
||||
|
||||
@@ -122,7 +122,16 @@
|
||||
NSPasteboard* pasteboard = info.draggingPasteboard;
|
||||
if ([pasteboard.types containsObject:GROUP_TABLE_VIEW_DATA_TYPE])
|
||||
{
|
||||
NSIndexSet* indexes = [NSKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:GROUP_TABLE_VIEW_DATA_TYPE]];
|
||||
NSIndexSet* indexes;
|
||||
if (@available(macOS 10.13, *))
|
||||
{
|
||||
indexes = [NSKeyedUnarchiver unarchivedObjectOfClass:NSIndexSet.class fromData:[pasteboard dataForType:GROUP_TABLE_VIEW_DATA_TYPE]
|
||||
error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
indexes = [NSKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:GROUP_TABLE_VIEW_DATA_TYPE]];
|
||||
}
|
||||
NSInteger oldRow = indexes.firstIndex;
|
||||
|
||||
if (oldRow < newRow)
|
||||
|
||||
@@ -71,12 +71,25 @@
|
||||
|
||||
_fTorrentCell = [[TorrentCell alloc] init];
|
||||
|
||||
NSData* groupData = [_fDefaults dataForKey:@"CollapsedGroups"];
|
||||
if (groupData)
|
||||
NSData* groupData;
|
||||
if ((groupData = [_fDefaults dataForKey:@"CollapsedGroupIndexes"]))
|
||||
{
|
||||
if (@available(macOS 10.13, *))
|
||||
{
|
||||
_fCollapsedGroups = [NSKeyedUnarchiver unarchivedObjectOfClass:NSMutableIndexSet.class fromData:groupData error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
_fCollapsedGroups = [NSKeyedUnarchiver unarchiveObjectWithData:groupData];
|
||||
}
|
||||
}
|
||||
else if ((groupData = [_fDefaults dataForKey:@"CollapsedGroups"])) //handle old groups
|
||||
{
|
||||
_fCollapsedGroups = [[NSUnarchiver unarchiveObjectWithData:groupData] mutableCopy];
|
||||
[_fDefaults removeObjectForKey:@"CollapsedGroups"];
|
||||
[self saveCollapsedGroups];
|
||||
}
|
||||
else
|
||||
if (_fCollapsedGroups == nil)
|
||||
{
|
||||
_fCollapsedGroups = [[NSMutableIndexSet alloc] init];
|
||||
}
|
||||
@@ -141,7 +154,7 @@
|
||||
|
||||
- (void)saveCollapsedGroups
|
||||
{
|
||||
[self.fDefaults setObject:[NSArchiver archivedDataWithRootObject:self.fCollapsedGroups] forKey:@"CollapsedGroups"];
|
||||
[self.fDefaults setObject:[NSKeyedArchiver archivedDataWithRootObject:self.fCollapsedGroups] forKey:@"CollapsedGroupIndexes"];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item
|
||||
|
||||
Reference in New Issue
Block a user