aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-10-14 21:40:56 +0000
committerrowanbeentje <rowan@beent.je>2012-10-14 21:40:56 +0000
commit5aa4c866a68098c65cc8268621da0cbdc2725986 (patch)
treed0e45cfa7fd5632770bbf12b6935d9dba5ba8afe
parentd8896ae0a22b0014d0b43706280c8a390f14b058 (diff)
downloadsequelpro-5aa4c866a68098c65cc8268621da0cbdc2725986.tar.gz
sequelpro-5aa4c866a68098c65cc8268621da0cbdc2725986.tar.bz2
sequelpro-5aa4c866a68098c65cc8268621da0cbdc2725986.zip
- Add names for most threads created by Sequel Pro for easier debug
-rw-r--r--Source/SPConnectionController.m5
-rw-r--r--Source/SPCustomQuery.m3
-rw-r--r--Source/SPDataImport.m13
-rw-r--r--Source/SPDatabaseDocument.m8
-rw-r--r--Source/SPDatabaseStructure.m3
-rw-r--r--Source/SPDatabaseViewController.m5
-rw-r--r--Source/SPExportController.m5
-rw-r--r--Source/SPFavoritesController.m12
-rw-r--r--Source/SPFavoritesExporter.m3
-rw-r--r--Source/SPFavoritesImporter.m5
-rw-r--r--Source/SPFileHandle.m1
-rw-r--r--Source/SPHistoryController.m3
-rw-r--r--Source/SPIndexesController.m5
-rw-r--r--Source/SPNavigatorController.m6
-rw-r--r--Source/SPPrintController.m1
-rw-r--r--Source/SPProcessListController.m3
-rw-r--r--Source/SPSSHTunnel.m3
-rw-r--r--Source/SPTableContent.m7
-rw-r--r--Source/SPTableContentDelegate.m3
-rw-r--r--Source/SPTableStructure.m5
-rw-r--r--Source/SPTableStructureLoading.m10
-rw-r--r--Source/SPTablesList.m22
-rw-r--r--Source/SPThreadAdditions.h39
-rw-r--r--Source/SPThreadAdditions.m47
-rw-r--r--Source/YRKSpinningProgressIndicator.m1
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj6
26 files changed, 169 insertions, 55 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 2e619285..acf270f9 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -51,6 +51,7 @@
#import "SPTreeNode.h"
#import "SPFavoritesExporter.h"
#import "SPFavoritesImporter.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -309,7 +310,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
// Cancel the MySQL connection - handing it off to a background thread - if one is present
if (mySQLConnection) {
[mySQLConnection setDelegate:nil];
- [NSThread detachNewThreadSelector:@selector(disconnect) toTarget:mySQLConnection withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPConnectionController cancellation background disconnect" target:mySQLConnection selector:@selector(disconnect) object:nil];
[mySQLConnection autorelease];
mySQLConnection = nil;
}
@@ -1789,7 +1790,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
dbDocument = nil;
if (mySQLConnection) {
[mySQLConnection setDelegate:nil];
- [NSThread detachNewThreadSelector:@selector(disconnect) toTarget:mySQLConnection withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPConnectionController close background disconnect" target:mySQLConnection selector:@selector(disconnect) object:nil];
[mySQLConnection autorelease];
mySQLConnection = nil;
}
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 411527e3..7c3083ec 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -57,6 +57,7 @@
#import "SPSplitView.h"
#import "SPTextView.h"
#import "RegexKitLite.h"
+#import "SPThreadAdditions.h"
#ifndef SP_REFACTOR /* headers */
#import "SPAppController.h"
#import "SPBundleHTMLOutputController.h"
@@ -548,7 +549,7 @@
// If a helper thread is already running, execute inline - otherwise detach a new thread for the queries
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(performQueriesTask:) toTarget:self withObject:taskArguments];
+ [NSThread detachNewThreadWithName:@"SPCustomQuery query perform task" target:self selector:@selector(performQueriesTask:) object:taskArguments];
}
else {
[self performQueriesTask:taskArguments];
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index 3a2f3004..027b7113 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -47,6 +47,7 @@
#import "SPFieldMapperController.h"
#import "SPFileHandle.h"
#import "SPEncodingPopupAccessory.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
#import <UniversalDetector/UniversalDetector.h>
@@ -263,8 +264,8 @@
if (importFileName == nil) return;
- // begin import process
- [NSThread detachNewThreadSelector:@selector(_importBackgroundProcess:) toTarget:self withObject:importFileName];
+ // Begin import process
+ [NSThread detachNewThreadWithName:@"SPDataImport background import task" target:self selector:@selector(_importBackgroundProcess:) object:importFileName];
}
@@ -334,7 +335,7 @@
if (importFileName == nil) return;
// Begin the import process
- [NSThread detachNewThreadSelector:@selector(_importBackgroundProcess:) toTarget:self withObject:importFileName];
+ [NSThread detachNewThreadWithName:@"SPDataImport background import task" target:self selector:@selector(_importBackgroundProcess:) object:importFileName];
}
/**
@@ -343,7 +344,7 @@
- (void)startSQLImportProcessWithFile:(NSString *)filename
{
[importFormatPopup selectItemWithTitle:@"SQL"];
- [NSThread detachNewThreadSelector:@selector(_importBackgroundProcess:) toTarget:self withObject:filename];
+ [NSThread detachNewThreadWithName:@"SPDataImport background import task" target:self selector:@selector(_importBackgroundProcess:) object:filename];
}
#pragma mark -
@@ -680,7 +681,7 @@
[tablesListInstance updateTables:self];
// Re-query the structure of all databases in the background
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
// Import finished Growl notification
[[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished"
@@ -1202,7 +1203,7 @@
[tablesListInstance performSelectorOnMainThread:@selector(updateTables:) withObject:self waitUntilDone:YES];
// Re-query the structure of all databases in the background
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
// Select the new table
[tablesListInstance selectItemWithName:selectedTableTarget];
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 7f2abab6..63381d90 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -96,6 +96,7 @@ enum {
#import "SPBundleHTMLOutputController.h"
#import "SPConnectionDelegate.h"
#endif
+#import "SPThreadAdditions.h"
#ifdef SP_REFACTOR /* headers */
#import "SPAlertSheets.h"
@@ -549,7 +550,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[self startTaskWithDescription:NSLocalizedString(@"Restoring session...", @"Restoring session task description")];
if ([NSThread isMainThread])
- [NSThread detachNewThreadSelector:@selector(restoreSession) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPDatabaseDocument session load task" target:self selector:@selector(restoreSession) object:nil];
else
[self restoreSession];
}
@@ -731,7 +732,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
NSDictionary *selectionDetails = [NSDictionary dictionaryWithObjectsAndKeys:database, @"database", item, @"item", nil];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_selectDatabaseAndItem:) toTarget:self withObject:selectionDetails];
+ [NSThread detachNewThreadWithName:@"SPDatabaseDocument database and table load task" target:self selector:@selector(_selectDatabaseAndItem:) object:selectionDetails];
}
else {
[self _selectDatabaseAndItem:selectionDetails];
@@ -966,8 +967,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[self _addDatabase];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:databaseStructureRetrieval withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
-
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:databaseStructureRetrieval selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
else {
// Reset chooseDatabaseButton
diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m
index 2ceb2728..c342e2cb 100644
--- a/Source/SPDatabaseStructure.m
+++ b/Source/SPDatabaseStructure.m
@@ -35,6 +35,7 @@
#import "SPConnectionDelegate.h"
#import "SPTablesList.h"
#import "RegexKitLite.h"
+#import "SPThreadAdditions.h"
#import <pthread.h>
@@ -104,7 +105,7 @@
{
// Perform the task in a background thread to avoid blocking the UI
- [NSThread detachNewThreadSelector:@selector(_cloneConnectionFromConnection:) toTarget:self withObject:aConnection];
+ [NSThread detachNewThreadWithName:@"SPDatabaseStructure clone connection task" target:self selector:@selector(_cloneConnectionFromConnection:) object:aConnection];
}
/**
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index 1bcbcf03..defc8e26 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -41,6 +41,7 @@
#import "SPTableData.h"
#import "SPTablesList.h"
#import "SPTableTriggers.h"
+#import "SPThreadAdditions.h"
#ifdef SP_REFACTOR /* headers */
#import "SPTableStructure.h"
#import "SPTableStructureLoading.h"
@@ -283,7 +284,7 @@
{
[self startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), [self table]]];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_loadTabTask:) toTarget:self withObject:tabViewItem];
+ [NSThread detachNewThreadWithName:@"SPDatabaseViewController view load task" target:self selector:@selector(_loadTabTask:) object:tabViewItem];
} else {
[self _loadTabTask:tabViewItem];
}
@@ -359,7 +360,7 @@
// If on the main thread, fire up a thread to deal with view changes and data loading;
// if already on a background thread, make the changes on the existing thread.
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_loadTableTask) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPDatabaseViewController table load task" target:self selector:@selector(_loadTableTask) object:nil];
} else {
[self _loadTableTask];
}
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index ef83ea7e..b014cd4e 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -41,6 +41,7 @@
#import "SPExportFilenameUtilities.h"
#import "SPExportFileNameTokenObject.h"
#import "SPDatabaseDocument.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -1046,8 +1047,8 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
[uiStateDict setObject:[NSNumber numberWithInteger:[exportSQLIncludeStructureCheck state]] forKey:SPSQLExportStructureEnabled];
[uiStateDict setObject:[NSNumber numberWithInteger:[exportSQLIncludeContentCheck state]] forKey:SPSQLExportContentEnabled];
[uiStateDict setObject:[NSNumber numberWithInteger:[exportSQLIncludeDropSyntaxCheck state]] forKey:SPSQLExportDropEnabled];
-
- [NSThread detachNewThreadSelector:@selector(_toggleExportButton:) toTarget:self withObject:uiStateDict];
+
+ [NSThread detachNewThreadWithName:@"SPExportController export button updater" target:self selector:@selector(_toggleExportButton:) object:uiStateDict];
[uiStateDict release];
}
diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m
index e7c441fe..7958fea5 100644
--- a/Source/SPFavoritesController.m
+++ b/Source/SPFavoritesController.m
@@ -34,6 +34,7 @@
#import "SPFavoriteNode.h"
#import "SPTreeNode.h"
#import "SPGroupNode.h"
+#import "SPThreadAdditions.h"
#import "pthread.h"
static SPFavoritesController *sharedFavoritesController = nil;
@@ -113,11 +114,12 @@ static SPFavoritesController *sharedFavoritesController = nil;
- (void)saveFavorites
{
pthread_mutex_lock(&favoritesLock);
-
- [NSThread detachNewThreadSelector:@selector(_saveFavoritesData:)
- toTarget:self
- withObject:[[[favoritesTree childNodes] objectAtIndex:0] dictionaryRepresentation]];
-
+
+ [NSThread detachNewThreadWithName:@"SPFavoritesController background favorite save task"
+ target:self
+ selector:@selector(_saveFavoritesData:)
+ object:[[[favoritesTree childNodes] objectAtIndex:0] dictionaryRepresentation]];
+
pthread_mutex_unlock(&favoritesLock);
}
diff --git a/Source/SPFavoritesExporter.m b/Source/SPFavoritesExporter.m
index 0d664bfa..a4544a5e 100644
--- a/Source/SPFavoritesExporter.m
+++ b/Source/SPFavoritesExporter.m
@@ -32,6 +32,7 @@
#import "SPFavoritesExporter.h"
#import "SPTreeNode.h"
+#import "SPThreadAdditions.h"
@interface SPFavoritesExporter ()
@@ -57,7 +58,7 @@
[self setExportFavorites:favorites];
[self setExportPath:path];
- [NSThread detachNewThreadSelector:@selector(_writeFavoritesInBackground) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPFavoritesExporter background writing thread" target:self selector:@selector(_writeFavoritesInBackground) object:nil];
}
/**
diff --git a/Source/SPFavoritesImporter.m b/Source/SPFavoritesImporter.m
index 90c41927..3a0c2099 100644
--- a/Source/SPFavoritesImporter.m
+++ b/Source/SPFavoritesImporter.m
@@ -31,6 +31,7 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPFavoritesImporter.h"
+#import "SPThreadAdditions.h"
@interface SPFavoritesImporter ()
@@ -54,8 +55,8 @@
- (void)importFavoritesFromFileAtPath:(NSString *)path
{
[self setImportPath:path];
-
- [NSThread detachNewThreadSelector:@selector(_importFavoritesInBackground) toTarget:self withObject:nil];
+
+ [NSThread detachNewThreadWithName:@"SPFavoritesImporter background favorite importer" target:self selector:@selector(_importFavoritesInBackground) object:nil];
}
#pragma mark -
diff --git a/Source/SPFileHandle.m b/Source/SPFileHandle.m
index f15b89e0..6ba49182 100644
--- a/Source/SPFileHandle.m
+++ b/Source/SPFileHandle.m
@@ -145,6 +145,7 @@
else if (fileMode == O_WRONLY) {
useCompression = NO;
processingThread = [[NSThread alloc] initWithTarget:self selector:@selector(_writeBufferToData) object:nil];
+ [processingThread setName:@"SPFileHandle data writing thread"];
[processingThread start];
}
}
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m
index d0d1c546..55a2f356 100644
--- a/Source/SPHistoryController.m
+++ b/Source/SPHistoryController.m
@@ -35,6 +35,7 @@
#import "SPTablesList.h"
#import "SPHistoryController.h"
#import "SPDatabaseViewController.h"
+#import "SPThreadAdditions.h"
@implementation SPHistoryController
@@ -386,7 +387,7 @@
// Start the task and perform the load
[theDocument startTaskWithDescription:NSLocalizedString(@"Loading history entry...", @"Loading history entry task desc")];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(loadEntryTaskWithPosition:) toTarget:self withObject:[NSNumber numberWithUnsignedInteger:position]];
+ [NSThread detachNewThreadWithName:@"SPHistoryController load of history entry" target:self selector:@selector(loadEntryTaskWithPosition:) object:[NSNumber numberWithUnsignedInteger:position]];
} else {
[self loadEntryTaskWithPosition:[NSNumber numberWithUnsignedInteger:position]];
}
diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m
index caaa5033..f2a26ef1 100644
--- a/Source/SPIndexesController.m
+++ b/Source/SPIndexesController.m
@@ -41,6 +41,7 @@
#import "SPDatabaseViewController.h"
#import "SPTableStructure.h"
#import "SPTableStructureLoading.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -656,7 +657,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize";
#endif
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_addIndexUsingDetails:) toTarget:self withObject:indexDetails];
+ [NSThread detachNewThreadWithName:@"SPIndexesController index creation thread" target:self selector:@selector(_addIndexUsingDetails:) object:indexDetails];
[dbDocument enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
}
@@ -684,7 +685,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize";
[indexDetails setObject:[NSNumber numberWithBool:[(NSString *)contextInfo hasSuffix:@"AndForeignKey"]] forKey:@"RemoveForeignKey"];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_removeIndexUsingDetails:) toTarget:self withObject:indexDetails];
+ [NSThread detachNewThreadWithName:@"SPIndexesController index removal thread" target:self selector:@selector(_removeIndexUsingDetails:) object:indexDetails];
[dbDocument enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
}
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 2b9fe902..82bf42f8 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -43,6 +43,7 @@
#import "SPAppController.h"
#import "SPDatabaseViewController.h"
#import "SPDatabaseStructure.h"
+#import "SPThreadAdditions.h"
#import <objc/message.h>
#import <SPMySQL/SPMySQL.h>
@@ -611,8 +612,8 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
isFiltered = NO;
if (![[doc getConnection] isConnected]) return;
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[doc databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[doc databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
- (IBAction)outlineViewAction:(id)sender
@@ -710,8 +711,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
[schemaDataFiltered setDictionary:structure];
- [NSThread detachNewThreadSelector:@selector(reloadAfterFiltering) toTarget:self withObject:nil];
-
+ [NSThread detachNewThreadWithName:@"SPNavigatorController update after filtering" target:self selector:@selector(reloadAfterFiltering) object:nil];
}
@catch(id ae)
{
diff --git a/Source/SPPrintController.m b/Source/SPPrintController.m
index 8100e218..5c4ad477 100644
--- a/Source/SPPrintController.m
+++ b/Source/SPPrintController.m
@@ -166,6 +166,7 @@
if ([NSThread isMainThread]) {
printThread = [[NSThread alloc] initWithTarget:self selector:(isTableInformation) ? @selector(generateTableInfoHTMLForPrinting) : @selector(generateHTMLForPrinting) object:nil];
+ [printThread setName:@"SPPrintController document generator"];
[self enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:@selector(generateHTMLForPrintingCallback)];
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m
index c958edc3..3b497448 100644
--- a/Source/SPProcessListController.m
+++ b/Source/SPProcessListController.m
@@ -35,6 +35,7 @@
#import "SPAlertSheets.h"
#import "SPAppController.h"
#import "SPDataCellFormatter.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -226,7 +227,7 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id";
processListThreadRunning = YES;
// Get the processes list on a background thread
- [NSThread detachNewThreadSelector:@selector(_getDatabaseProcessListInBackground:) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPProcessListController retrieving process list" target:self selector:@selector(_getDatabaseProcessListInBackground:) object:nil];
}
/**
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index 66db2a9e..467c43fc 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -36,6 +36,7 @@
#import "RegexKitLite.h"
#import "SPKeychain.h"
#import "SPAlertSheets.h"
+#import "SPThreadAdditions.h"
#import <netinet/in.h>
#import <CommonCrypto/CommonDigest.h>
@@ -218,7 +219,7 @@
[debugMessagesLock lock];
[debugMessages removeAllObjects];
[debugMessagesLock unlock];
- [NSThread detachNewThreadSelector:@selector(launchTask:) toTarget: self withObject: nil ];
+ [NSThread detachNewThreadWithName:@"SPSSHTunnel SSH binary communication task" target:self selector:@selector(launchTask:) object:nil];
}
/*
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 8296ca75..25830946 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -63,6 +63,7 @@
#import "SPBundleHTMLOutputController.h"
#endif
#import "SPCustomQuery.h"
+#import "SPThreadAdditions.h"
#import <pthread.h>
#import <SPMySQL/SPMySQL.h>
@@ -1451,7 +1452,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
[tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Reloading data...", @"Reloading data task description")];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(reloadTableTask) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPTableContent table reload task" target:self selector:@selector(reloadTableTask) object:nil];
} else {
[self reloadTableTask];
}
@@ -1541,7 +1542,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
[tableDocumentInstance startTaskWithDescription:taskString];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(filterTableTask) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPTableContent filter table task" target:self selector:@selector(filterTableTask) object:nil];
} else {
[self filterTableTask];
}
@@ -2560,7 +2561,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
// If on the main thread, fire up a thread to perform the load while keeping the modification flag
[tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Loading reference...", @"Loading referece task string")];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(clickLinkArrowTask:) toTarget:self withObject:theArrowCell];
+ [NSThread detachNewThreadWithName:@"SPTableContent linked data load task" target:self selector:@selector(clickLinkArrowTask:) object:theArrowCell];
} else {
[self clickLinkArrowTask:theArrowCell];
}
diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m
index 9cae98d8..e0064337 100644
--- a/Source/SPTableContentDelegate.m
+++ b/Source/SPTableContentDelegate.m
@@ -47,6 +47,7 @@
#import "SPAlertSheets.h"
#import "SPTableData.h"
#import "SPFieldEditorController.h"
+#import "SPThreadAdditions.h"
#import <pthread.h>
#import <SPMySQL/SPMySQL.h>
@@ -77,7 +78,7 @@
[tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Sorting table...", @"Sorting table task description")];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(sortTableTaskWithColumn:) toTarget:self withObject:tableColumn];
+ [NSThread detachNewThreadWithName:@"SPTableContent table sort task" target:self selector:@selector(sortTableTaskWithColumn:) object:tableColumn];
}
else {
[self sortTableTaskWithColumn:tableColumn];
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index baf2a6f4..02defd7c 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -45,6 +45,7 @@
#import "RegexKitLite.h"
#import "SPTableFieldValidation.h"
#import "SPTableStructureLoading.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -516,7 +517,7 @@
NSNumber *removeKey = [NSNumber numberWithBool:[(NSString *)contextInfo hasSuffix:@"AndForeignKey"]];
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_removeFieldAndForeignKey:) toTarget:self withObject:removeKey];
+ [NSThread detachNewThreadWithName:@"SPTableStructure field and key removal task" target:self selector:@selector(_removeFieldAndForeignKey:) object:removeKey];
[tableDocumentInstance enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
}
@@ -944,7 +945,7 @@
[tableDocumentInstance setContentRequiresReload:YES];
// Query the structure of all databases in the background
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", selectedTable, @"affectedItem", [NSNumber numberWithInteger:[tablesListInstance tableType]], @"affectedItemType", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", selectedTable, @"affectedItem", [NSNumber numberWithInteger:[tablesListInstance tableType]], @"affectedItemType", nil]];
return YES;
}
diff --git a/Source/SPTableStructureLoading.m b/Source/SPTableStructureLoading.m
index 99406f7a..4d7bb4dd 100644
--- a/Source/SPTableStructureLoading.m
+++ b/Source/SPTableStructureLoading.m
@@ -36,6 +36,7 @@
#import "SPDatabaseViewController.h"
#import "SPIndexesController.h"
#import "SPTablesList.h"
+#import "SPThreadAdditions.h"
#import <SPMySQL/SPMySQL.h>
@@ -285,10 +286,11 @@
[tableDocumentInstance setStatusRequiresReload:YES];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:)
- toTarget:[tableDocumentInstance databaseStructureRetrieval]
- withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
-
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier"
+ target:[tableDocumentInstance databaseStructureRetrieval]
+ selector:@selector(queryDbStructureWithUserInfo:)
+ object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+
[self loadTable:selectedTable];
}
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index 4da69390..8d0d6bbc 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -59,6 +59,7 @@
#import "SPAppController.h"
#import "SPSplitView.h"
#endif
+#import "SPThreadAdditions.h"
#ifdef SP_REFACTOR
#import "SQLSidebarViewController.h"
@@ -355,10 +356,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
// Query the structure of all databases in the background
if (sender == self)
// Invoked by SP
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:nil];
else
// User press refresh button ergo force update
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", [NSNumber numberWithBool:YES], @"cancelQuerying", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", [NSNumber numberWithBool:YES], @"cancelQuerying", nil]];
}
/**
@@ -1525,7 +1526,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
#endif
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
#ifndef SP_REFACTOR
@@ -2161,8 +2162,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
#endif
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
-
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
#ifndef SP_REFACTOR /* operations performed on whole tables */
@@ -2216,7 +2216,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
{
// Ensure the task is performed on a background thread to group addition and loads
if ([NSThread isMainThread]) {
- [NSThread detachNewThreadSelector:@selector(_addTable) toTarget:self withObject:nil];
+ [NSThread detachNewThreadWithName:@"SPTablesList table addition task" target:self selector:@selector(_addTable) object:nil];
return;
}
@@ -2308,9 +2308,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
#endif
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:)
- toTarget:[tableDocumentInstance databaseStructureRetrieval]
- withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier"
+ target:[tableDocumentInstance databaseStructureRetrieval]
+ selector:@selector(queryDbStructureWithUserInfo:)
+ object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
else {
// Error while creating new table
@@ -2517,8 +2518,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
-
+ [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
}
}
diff --git a/Source/SPThreadAdditions.h b/Source/SPThreadAdditions.h
new file mode 100644
index 00000000..a053a5f4
--- /dev/null
+++ b/Source/SPThreadAdditions.h
@@ -0,0 +1,39 @@
+//
+// $Id$
+//
+// SPThreadAdditions.h
+// sequel-pro
+//
+// Created by Rowan Beentje on October 14th, 2012.
+// Copyright (c) 2012 Rowan Beentje. 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 <http://code.google.com/p/sequel-pro/>
+
+@interface NSThread (SPThreadAdditions)
+
+// Provide a utility class method, providing functionality similar to
+// +detachNewThreadSelector:toTarget:withObject: but allowing easy naming
++ (void)detachNewThreadWithName:(NSString *)aName target:(id)aTarget selector:(SEL)aSelector object:(id)anArgument;
+
+@end
diff --git a/Source/SPThreadAdditions.m b/Source/SPThreadAdditions.m
new file mode 100644
index 00000000..75e86225
--- /dev/null
+++ b/Source/SPThreadAdditions.m
@@ -0,0 +1,47 @@
+//
+// $Id$
+//
+// SPThreadAdditions.m
+// sequel-pro
+//
+// Created by Rowan Beentje on October 14th, 2012.
+// Copyright (c) 2012 Rowan Beentje. 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 <http://code.google.com/p/sequel-pro/>
+
+#import "SPThreadAdditions.h"
+
+@implementation NSThread (SPThreadAdditions)
+
++ (void)detachNewThreadWithName:(NSString *)aName target:(id)aTarget selector:(SEL)aSelector object:(id)anArgument
+{
+ NSThread *newThread = [[NSThread alloc] initWithTarget:aTarget selector:aSelector object:anArgument];
+ if (aName) {
+ [newThread setName:aName];
+ }
+ [newThread start];
+ [newThread autorelease];
+}
+
+@end
diff --git a/Source/YRKSpinningProgressIndicator.m b/Source/YRKSpinningProgressIndicator.m
index f34f1d4a..c706e17a 100644
--- a/Source/YRKSpinningProgressIndicator.m
+++ b/Source/YRKSpinningProgressIndicator.m
@@ -225,6 +225,7 @@
// Why animate if not visible? viewDidMoveToWindow will re-call this method when needed.
if (_usesThreadedAnimation) {
_animationThread = [[NSThread alloc] initWithTarget:self selector:@selector(animateInBackgroundThread) object:nil];
+ [_animationThread setName:@"YRKSpinningProgressIndicator animator"];
[_animationThread start];
}
else {
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index a666fe74..d9c2072e 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -212,6 +212,7 @@
5843DA6D161FA35600EAA6D1 /* key-icon-alternate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5843DA69161FA35600EAA6D1 /* key-icon-alternate@2x.png */; };
5843DA6E161FA35600EAA6D1 /* key-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 5843DA6A161FA35600EAA6D1 /* key-icon.png */; };
5843DA6F161FA35600EAA6D1 /* key-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5843DA6B161FA35600EAA6D1 /* key-icon@2x.png */; };
+ 5843E247162B555B00EAA6D1 /* SPThreadAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5843E246162B555B00EAA6D1 /* SPThreadAdditions.m */; };
584754D3120A05910057631F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 584754D0120A05910057631F /* GeneratePreviewForURL.m */; };
584754D4120A05910057631F /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 584754D1120A05910057631F /* GenerateThumbnailForURL.m */; };
584754D5120A05910057631F /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 584754D2120A05910057631F /* main.c */; };
@@ -933,6 +934,8 @@
5843DA69161FA35600EAA6D1 /* key-icon-alternate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "key-icon-alternate@2x.png"; sourceTree = "<group>"; };
5843DA6A161FA35600EAA6D1 /* key-icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "key-icon.png"; sourceTree = "<group>"; };
5843DA6B161FA35600EAA6D1 /* key-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "key-icon@2x.png"; sourceTree = "<group>"; };
+ 5843E245162B555B00EAA6D1 /* SPThreadAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPThreadAdditions.h; sourceTree = "<group>"; };
+ 5843E246162B555B00EAA6D1 /* SPThreadAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPThreadAdditions.m; sourceTree = "<group>"; };
584754C2120A04560057631F /* Sequel Pro.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Sequel Pro.qlgenerator"; sourceTree = BUILT_PRODUCTS_DIR; };
584754D0120A05910057631F /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = "<group>"; };
584754D1120A05910057631F /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = "<group>"; };
@@ -2588,6 +2591,8 @@
584D878A15140FEB00F24774 /* SPObjectAdditions.m */,
B52460D50F8EF92300171639 /* SPTextViewAdditions.h */,
B52460D60F8EF92300171639 /* SPTextViewAdditions.m */,
+ 5843E245162B555B00EAA6D1 /* SPThreadAdditions.h */,
+ 5843E246162B555B00EAA6D1 /* SPThreadAdditions.m */,
B57747D70F7A8990003B34F9 /* SPWindowAdditions.h */,
B57747D80F7A8990003B34F9 /* SPWindowAdditions.m */,
BC2C16D20FEBEDF10003993B /* SPDataAdditions.h */,
@@ -3328,6 +3333,7 @@
58DF9F7315AB8509003B4330 /* SPSplitView.m in Sources */,
58DFC91615CB3501003B4330 /* BGHUDButtonCell.m in Sources */,
171B374115DA654300EBC7AB /* SPTableContentFilter.m in Sources */,
+ 5843E247162B555B00EAA6D1 /* SPThreadAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};