aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2018-01-13 06:38:54 +0100
committerMax <post@wickenrode.com>2018-01-13 06:38:54 +0100
commitf44727df6b26e4af700d955823f7345cff35a487 (patch)
tree59de10e6c93c0487e87776db035e470179110cb6
parent9c2f82c0f7326d71070731ce8248f164c00e06aa (diff)
downloadsequelpro-f44727df6b26e4af700d955823f7345cff35a487.tar.gz
sequelpro-f44727df6b26e4af700d955823f7345cff35a487.tar.bz2
sequelpro-f44727df6b26e4af700d955823f7345cff35a487.zip
Replace all calls to deprecated method +propertyListFromData:mutabilityOption:format:errorDescription:
-rw-r--r--Source/SPContentFilterManager.m19
-rw-r--r--Source/SPDatabaseDocument.m56
-rw-r--r--Source/SPEditorPreferencePane.m14
-rw-r--r--Source/SPFavoritesController.m56
-rw-r--r--Source/SPFavoritesExporter.m23
-rw-r--r--Source/SPPreferencesUpgrade.m23
-rw-r--r--Source/SPQueryFavoriteManager.m19
7 files changed, 95 insertions, 115 deletions
diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m
index 0898d430..c8991943 100644
--- a/Source/SPContentFilterManager.m
+++ b/Source/SPContentFilterManager.m
@@ -943,27 +943,26 @@ static NSString *SPExportFilterAction = @"SPExportFilter";
[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
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 1d2861c6..358f9946 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3309,25 +3309,25 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
[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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[[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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
// 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 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
return YES;
-
}
/**
diff --git a/Source/SPEditorPreferencePane.m b/Source/SPEditorPreferencePane.m
index c09e1fe8..00a63ca6 100644
--- a/Source/SPEditorPreferencePane.m
+++ b/Source/SPEditorPreferencePane.m
@@ -895,17 +895,18 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined";
[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];
@@ -913,7 +914,6 @@ static NSString *SPCustomColorSchemeNameLC = @"user-defined";
return;
}
- NSError *error = nil;
[plist writeToFile:path options:NSAtomicWrite error:&error];
if (error) [[NSAlert alertWithError:error] runModal];
diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m
index 625b46cc..e152a27f 100644
--- a/Source/SPFavoritesController.m
+++ b/Source/SPFavoritesController.m
@@ -254,10 +254,7 @@ static SPFavoritesController *sharedFavoritesController = nil;
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 @@ static SPFavoritesController *sharedFavoritesController = nil;
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,12 +389,10 @@ static SPFavoritesController *sharedFavoritesController = nil;
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
@@ -409,13 +400,13 @@ static SPFavoritesController *sharedFavoritesController = nil;
// 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 @@ static SPFavoritesController *sharedFavoritesController = nil;
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 @@ static SPFavoritesController *sharedFavoritesController = nil;
// 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 @@ static SPFavoritesController *sharedFavoritesController = nil;
[fileManager removeItemAtPath:favoritesBackupFile error:NULL];
}
+end_cleanup:
pthread_mutex_unlock(&writeLock);
[pool release];
diff --git a/Source/SPFavoritesExporter.m b/Source/SPFavoritesExporter.m
index d37ce07d..419a24c3 100644
--- a/Source/SPFavoritesExporter.m
+++ b/Source/SPFavoritesExporter.m
@@ -66,9 +66,6 @@
{
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 @@
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];
diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m
index 11cd146c..9cd0d471 100644
--- a/Source/SPPreferencesUpgrade.m
+++ b/Source/SPPreferencesUpgrade.m
@@ -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];
}
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index a31c9bd0..4351ae52 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -935,24 +935,25 @@
[spfdata setObject:favoriteData forKey:SPQueryFavorites];
- 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 query favorite data", @"error while converting query favorite data")]
+ if(error) {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while converting query favorite data", @"error while converting query favorite data")
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];