aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDataImport.m51
-rw-r--r--Source/SPFunctions.h33
-rw-r--r--Source/SPFunctions.m41
3 files changed, 101 insertions, 24 deletions
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index aa50a827..5cf67976 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -47,6 +47,7 @@
#import "SPFileHandle.h"
#import "SPEncodingPopupAccessory.h"
#import "SPThreadAdditions.h"
+#import "SPFunctions.h"
#import <SPMySQL/SPMySQL.h>
@@ -401,18 +402,20 @@
BOOL useIndeterminate = NO;
if ([sqlFileHandle compressionFormat] == SPBzip2Compression) useIndeterminate = YES;
- // Reset progress interface
- [errorsView setString:@""];
- [[singleProgressTitle onMainThread] setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")];
- [[singleProgressText onMainThread] setStringValue:NSLocalizedString(@"Reading...", @"text showing that app is reading dump")];
- [[singleProgressBar onMainThread] setIndeterminate:useIndeterminate];
- [[singleProgressBar onMainThread] setMaxValue:fileTotalLength];
- [[singleProgressBar onMainThread] setUsesThreadedAnimation:YES];
- [[singleProgressBar onMainThread] startAnimation:self];
-
- // Open the progress sheet
- [[NSApp onMainThread] beginSheet:singleProgressSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];
- [[singleProgressSheet onMainThread] makeKeyWindow];
+ SPMainQSync(^{
+ // Reset progress interface
+ [errorsView setString:@""];
+ [singleProgressTitle setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")];
+ [singleProgressText setStringValue:NSLocalizedString(@"Reading...", @"text showing that app is reading dump")];
+ [singleProgressBar setIndeterminate:useIndeterminate];
+ [singleProgressBar setMaxValue:fileTotalLength];
+ [singleProgressBar setUsesThreadedAnimation:YES];
+ [singleProgressBar startAnimation:self];
+
+ // Open the progress sheet
+ [NSApp beginSheet:singleProgressSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];
+ [singleProgressSheet makeKeyWindow];
+ });
[tableDocumentInstance setQueryMode:SPImportExportQueryMode];
@@ -568,18 +571,18 @@
// If not set to ignore errors, ask what to do. Use NSAlert rather than
// SPBeginWaitingAlertSheet as there is already a modal sheet in progress.
if (!ignoreSQLErrors) {
- NSInteger sqlImportErrorSheetReturnCode;
-
- NSAlert *sqlErrorAlert = [NSAlert
- alertWithMessageText:NSLocalizedString(@"An error occurred while importing SQL", @"sql import error message")
- defaultButton:NSLocalizedString(@"Continue", @"continue button")
- alternateButton:NSLocalizedString(@"Ignore All Errors", @"ignore errors button")
- otherButton:NSLocalizedString(@"Stop", @"stop button")
- informativeTextWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection lastErrorMessage]
- ];
- [sqlErrorAlert setAlertStyle:NSWarningAlertStyle];
- sqlImportErrorSheetReturnCode = [sqlErrorAlert runModal];
-
+ __block NSInteger sqlImportErrorSheetReturnCode;
+
+ SPMainQSync(^{
+ NSAlert *sqlErrorAlert = [NSAlert alertWithMessageText:NSLocalizedString(@"An error occurred while importing SQL", @"sql import error message")
+ defaultButton:NSLocalizedString(@"Continue", @"continue button")
+ alternateButton:NSLocalizedString(@"Ignore All Errors", @"ignore errors button")
+ otherButton:NSLocalizedString(@"Stop", @"stop button")
+ informativeTextWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection lastErrorMessage]];
+ [sqlErrorAlert setAlertStyle:NSWarningAlertStyle];
+ sqlImportErrorSheetReturnCode = [sqlErrorAlert runModal];
+ });
+
switch (sqlImportErrorSheetReturnCode) {
// On "continue", no additional action is required
diff --git a/Source/SPFunctions.h b/Source/SPFunctions.h
new file mode 100644
index 00000000..f2ca9c7e
--- /dev/null
+++ b/Source/SPFunctions.h
@@ -0,0 +1,33 @@
+//
+// SPFunctions.h
+// sequel-pro
+//
+// Created by Max Lohrmann on 01.10.15.
+// Copyright (c) 2015 Max Lohrmann. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// More info at <https://github.com/sequelpro/sequelpro>
+
+
+void SPMainQSync(void (^block)(void));
+
diff --git a/Source/SPFunctions.m b/Source/SPFunctions.m
new file mode 100644
index 00000000..f485d36a
--- /dev/null
+++ b/Source/SPFunctions.m
@@ -0,0 +1,41 @@
+//
+// SPFunctions.m
+// sequel-pro
+//
+// Created by Max Lohrmann on 01.10.15.
+// Copyright (c) 2015 Max Lohrmann. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// More info at <https://github.com/sequelpro/sequelpro>
+
+#import "SPFunctions.h"
+
+void SPMainQSync(void (^block)(void))
+{
+ if(dispatch_get_current_queue() == dispatch_get_main_queue()) {
+ block();
+ }
+ else {
+ dispatch_sync(dispatch_get_main_queue(), block);
+ }
+}