Permalink
Browse files

Replace all calls to deprecated method +propertyListFromData:mutabili…

…tyOption:format:errorDescription:
  • Loading branch information...
dmoagx committed Jan 13, 2018
1 parent 9c2f82c commit f44727df6b26e4af700d955823f7345cff35a487
@@ -943,27 +943,26 @@ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode co
[cfdata setObject:filterData forKey:filterType];
[spfdata setObject:cfdata forKey:SPContentFilters];

NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spfdata
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
NSError *error = nil;
NSData *plist = [NSPropertyListSerialization dataWithPropertyList:spfdata
format:NSPropertyListXMLFormat_v1_0
options:0
error:&error];

if(err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithString:NSLocalizedString(@"Error while converting content filter data", @"Content filters could not be converted to plist upon export - message title (ContentFilterManager)")]
if(error) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting content filter data", @"Content filters could not be converted to plist upon export - message title (ContentFilterManager)")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@", err];
otherButton:nil
informativeTextWithFormat:@"%@", [error localizedDescription]];

[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
return;
}

NSError *error = nil;
[plist writeToURL:[panel URL] options:NSAtomicWrite error:&error];
if (error) [[NSAlert alertWithError:error] runModal];

}
}
#endif
@@ -3309,25 +3309,25 @@ - (void)saveConnectionPanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)ret
}
[info setObject:windows forKey:@"windows"];

NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:info
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
error = nil;

NSData *plist = [NSPropertyListSerialization dataWithPropertyList:info
format:NSPropertyListXMLFormat_v1_0
options:0
error:&error];

if(err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting session data", @"error while converting session data")]
if(error) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting session data", @"error while converting session data")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@", err];
otherButton:nil
informativeTextWithFormat:@"%@", [error localizedDescription]];

[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];

return;
}

error = nil;

[plist writeToFile:[NSString stringWithFormat:@"%@/info.plist", fileName] options:NSAtomicWrite error:&error];

@@ -3437,27 +3437,27 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB
[spf setObject:[[SPQueryController sharedQueryController] contentFilterForFileURL:[self fileURL]] forKey:SPContentFilters];

// Save it again
NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spf
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
NSError *error = nil;
NSData *plist = [NSPropertyListSerialization dataWithPropertyList:spf
format:NSPropertyListXMLFormat_v1_0
options:0
error:&error];

[spf release];
if(err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")]
if(error) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@", err];
otherButton:nil
informativeTextWithFormat:@"%@", [error localizedDescription]];

[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
return NO;
}

NSError *error = nil;
[plist writeToFile:fileName options:NSAtomicWrite error:&error];
if(error != nil){
if(error != nil) {
NSAlert *errorAlert = [NSAlert alertWithError:error];
[errorAlert runModal];
return NO;
@@ -3466,7 +3466,6 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:fileName]];

return YES;

}

// Set up the dictionary to save to file, together with a data store
@@ -3536,24 +3535,24 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB
}

// Convert to plist
NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spfStructure
NSError *error = nil;
NSData *plist = [NSPropertyListSerialization dataWithPropertyList:spfStructure
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
options:0
error:&error];

if (err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")]
if (error) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@", err];
informativeTextWithFormat:@"%@", [error localizedDescription]];

[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
return NO;
}

NSError *error = nil;
[plist writeToFile:fileName options:NSAtomicWrite error:&error];
if (error != nil){
NSAlert *errorAlert = [NSAlert alertWithError:error];
@@ -3585,7 +3584,6 @@ - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInB
}

return YES;

}

/**
@@ -895,25 +895,25 @@ - (void)_saveColorThemeAtPath:(NSString *)path

[scheme setObject:settings forKey:@"settings"];

NSString *err = nil;
NSData *plist = [NSPropertyListSerialization dataFromPropertyList:scheme
NSError *error = nil;
NSData *plist = [NSPropertyListSerialization dataWithPropertyList:scheme
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
options:0
error:&error];

if(err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting color scheme data", @"error while converting color scheme data")]
if(error) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting color scheme data", @"error while converting color scheme data")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%@", err];
informativeTextWithFormat:@"%@", [error localizedDescription]];

[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];

return;
}

NSError *error = nil;
[plist writeToFile:path options:NSAtomicWrite error:&error];

if (error) [[NSAlert alertWithError:error] runModal];
@@ -254,10 +254,7 @@ - (void)_loadFavorites

if (error) {
NSLog(@"Error retrieving data directory path: %@", [error localizedDescription]);

pthread_mutex_unlock(&favoritesLock);

return;
goto end_cleanup;
}

NSString *favoritesFile = [dataPath stringByAppendingPathComponent:SPFavoritesDataFile];
@@ -270,31 +267,27 @@ - (void)_loadFavorites
NSMutableDictionary *newFavorites = [NSMutableDictionary dictionaryWithObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, @[], SPFavoriteChildrenKey, nil] forKey:SPFavoritesRootKey];

error = nil;
NSString *errorString = nil;

NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:newFavorites
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:newFavorites
format:NSPropertyListXMLFormat_v1_0
errorDescription:&errorString];
if (plistData) {
options:0
error:&error];
if (error) {
NSLog(@"Error converting default favorites data to plist format: %@", error);
goto end_cleanup;
}
else if (plistData) {
[plistData writeToFile:favoritesFile options:NSAtomicWrite error:&error];

if (error) {
NSLog(@"Error writing default favorites data: %@", [error localizedDescription]);
NSLog(@"Error writing default favorites data: %@", error);
}
}
else if (errorString) {
NSLog(@"Error converting default favorites data to plist format: %@", errorString);

[errorString release];

pthread_mutex_unlock(&favoritesLock);

return;
}

favoritesData = newFavorites;
}


end_cleanup:
pthread_mutex_unlock(&favoritesLock);
}

@@ -396,26 +389,24 @@ - (void)_saveFavoritesData:(NSDictionary *)data
pthread_mutex_lock(&writeLock);

if (!favoritesTree) {
pthread_mutex_unlock(&writeLock);
return;
goto end_cleanup;
}

NSError *error = nil;
NSString *errorString = nil;

// Before starting the file actions, attempt to create a dictionary
// from the current favourites tree and convert it to a dictionary representation
// to create the plist data. This is done before file changes as it can sometimes
// be terminated during shutdown.
NSDictionary *dictionary = @{SPFavoritesRootKey : data};

NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:dictionary
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:dictionary
format:NSPropertyListXMLFormat_v1_0
errorDescription:&errorString];
if (errorString) {
NSLog(@"Error converting favorites data to plist format: %@", errorString);

[errorString release];
options:0
error:&error];
if (error) {
NSLog(@"Error converting favorites data to plist format: %@", error);
goto end_cleanup;
}

NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -424,9 +415,7 @@ - (void)_saveFavoritesData:(NSDictionary *)data

if (error) {
NSLog(@"Error retrieving data directory path: %@", [error localizedDescription]);

pthread_mutex_unlock(&writeLock);
return;
goto end_cleanup;
}

NSString *favoritesFile = [dataPath stringByAppendingPathComponent:SPFavoritesDataFile];
@@ -445,9 +434,7 @@ - (void)_saveFavoritesData:(NSDictionary *)data
// We can't move it so try and delete it
if (![fileManager removeItemAtPath:favoritesFile error:&error] && error) {
NSLog(@"Unable to delete existing favorites data file during save. Something is wrong, permissions perhaps: %@", [error localizedDescription]);

pthread_mutex_unlock(&writeLock);
return;
goto end_cleanup;
}
}

@@ -471,6 +458,7 @@ - (void)_saveFavoritesData:(NSDictionary *)data
[fileManager removeItemAtPath:favoritesBackupFile error:NULL];
}

end_cleanup:
pthread_mutex_unlock(&writeLock);

[pool release];
@@ -66,9 +66,6 @@ - (void)_writeFavoritesInBackground
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSError *error = nil;
NSString *errorString = nil;

NSMutableArray *favorites = [[NSMutableArray alloc] init];

// Get a dictionary representation of all favorites
@@ -83,24 +80,24 @@ - (void)_writeFavoritesInBackground
NSDictionary *dictionary = @{SPFavoritesDataRootKey : favorites};

[favorites release];

// Convert the current favorites tree to a dictionary representation to create the plist data
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:dictionary
NSError *error = nil;
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:dictionary
format:NSPropertyListXMLFormat_v1_0
errorDescription:&errorString];
options:0
error:&error];

if (plistData) {
if (error) {
NSLog(@"Error converting favorites data to plist format: %@", error);
}
else if (plistData) {
[plistData writeToFile:[self exportPath] options:NSAtomicWrite error:&error];

if (error) {
NSLog(@"Error writing favorites data: %@", [error localizedDescription]);
NSLog(@"Error writing favorites data: %@", error);
}
}
else if (errorString) {
NSLog(@"Error converting favorites data to plist format: %@", errorString);

[errorString release];
}

[self _informDelegateOfExportCompletion:error];

@@ -414,29 +414,26 @@ void SPMigrateConnectionFavoritesData(void)
NSDictionary *newFavorites = @{SPFavoritesRootKey : [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, favorites, SPFavoriteChildrenKey, nil]};

error = nil;
NSString *errorString = nil;

NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:newFavorites
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:newFavorites
format:NSPropertyListXMLFormat_v1_0
errorDescription:&errorString];
if (plistData) {
options:0
error:&error];

if (error) {
NSLog(@"Error converting migrating favorites data to plist format: %@", error);
}
else if (plistData) {
[plistData writeToFile:favoritesFile options:NSAtomicWrite error:&error];

if (error) {
NSLog(@"Error migrating favorites data: %@", [error localizedDescription]);
NSLog(@"Error migrating favorites data: %@", error);
}
else {
[prefs removeObjectForKey:SPOldFavoritesKey];
}
}
else if (errorString) {
NSLog(@"Error converting migrating favorites data to plist format: %@", errorString);

[favorites release];
[errorString release];
return;
}


[favorites release];
}

Oops, something went wrong.

0 comments on commit f44727d

Please sign in to comment.