90
90
#include <libkern/OSAtomic.h>
91
91
92
92
// Constants
93
+ static NSString *SPCopyDatabaseAction = @"SPCopyDatabase";
93
94
static NSString *SPConfirmCopyDatabaseAction = @"SPConfirmCopyDatabase";
94
95
static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
95
96
static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
@@ -898,11 +899,11 @@ - (IBAction)copyDatabase:(id)sender
898
899
[databaseCopyNameField setStringValue:selectedDatabase];
899
900
[copyDatabaseMessageField setStringValue:selectedDatabase];
900
901
901
- [parentWindow beginSheet:databaseCopySheet completionHandler:^(NSInteger returnCode) {
902
- if (returnCode == NSOKButton) {
903
- [ self _copyDatabase];
904
- }
905
- } ];
902
+ [NSApp beginSheet:databaseCopySheet
903
+ modalForWindow:parentWindow
904
+ modalDelegate: self
905
+ didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
906
+ contextInfo:SPCopyDatabaseAction ];
906
907
}
907
908
908
909
/**
@@ -1110,14 +1111,19 @@ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSSt
1110
1111
}
1111
1112
}
1112
1113
}
1114
+ else if ([contextInfo isEqualToString:SPCopyDatabaseAction]) {
1115
+ if (returnCode == NSOKButton) {
1116
+ [self _copyDatabase];
1117
+ }
1118
+ }
1113
1119
else if ([contextInfo isEqualToString:SPRenameDatabaseAction]) {
1114
1120
if (returnCode == NSOKButton) {
1115
1121
[self _renameDatabase];
1116
1122
}
1117
1123
}
1118
- else if([contextInfo isEqualToString:SPAlterDatabaseAction]) {
1124
+ else if ([contextInfo isEqualToString:SPAlterDatabaseAction]) {
1119
1125
[alterDatabaseCharsetHelper setEnabled:NO];
1120
- if(returnCode == NSOKButton) {
1126
+ if (returnCode == NSOKButton) {
1121
1127
[self _alterDatabase];
1122
1128
}
1123
1129
}
@@ -5993,6 +5999,8 @@ - (void)setIsSavedInBundle:(BOOL)savedInBundle
5993
5999
5994
6000
/**
5995
6001
* Copies the current database (and optionally it's content) on a separate thread.
6002
+ *
6003
+ * This method *MUST* be called from the UI thread!
5996
6004
*/
5997
6005
- (void)_copyDatabase
5998
6006
{
@@ -6030,11 +6038,11 @@ - (void)_copyDatabaseWithDetails:(NSDictionary *)databaseDetails
6030
6038
6031
6039
[databaseCopy setConnection:[self getConnection]];
6032
6040
6033
- NSString *newDatabaseName = databaseDetails[ SPNewDatabaseName];
6041
+ NSString *newDatabaseName = [databaseDetails objectForKey: SPNewDatabaseName];
6034
6042
6035
- BOOL success = [databaseCopy copyDatabaseFrom:databaseDetails[ SPNewDatabaseDetails]
6043
+ BOOL success = [databaseCopy copyDatabaseFrom:[databaseDetails objectForKey: SPNewDatabaseDetails]
6036
6044
to:newDatabaseName
6037
- withContent:[databaseDetails[ SPNewDatabaseCopyContent] boolValue]];
6045
+ withContent:[[databaseDetails objectForKey: SPNewDatabaseCopyContent] boolValue]];
6038
6046
6039
6047
[databaseCopy release];
6040
6048
@@ -6047,15 +6055,13 @@ - (void)_copyDatabaseWithDetails:(NSDictionary *)databaseDetails
6047
6055
[self endTask];
6048
6056
6049
6057
if (!success) {
6050
- SPMainQSync(^{
6051
- SPOnewayAlertSheet(
6052
- NSLocalizedString(@"Unable to copy database", @"unable to copy database message"),
6053
- parentWindow,
6054
- [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to copy the database '%@' to '%@'.", @"unable to copy database message informative message"),
6055
- [databaseDetails[SPNewDatabaseDetails] databaseName],
6056
- newDatabaseName]
6057
- );
6058
- });
6058
+ SPOnewayAlertSheet(
6059
+ NSLocalizedString(@"Unable to copy database", @"unable to copy database message"),
6060
+ parentWindow,
6061
+ [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to copy the database '%@' to '%@'.", @"unable to copy database message informative message"),
6062
+ [databaseDetails[SPNewDatabaseDetails] databaseName],
6063
+ newDatabaseName]
6064
+ );
6059
6065
}
6060
6066
}
6061
6067
}
0 commit comments