From 877d17d13ed242203393a4cf3d35231674bcb78a Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 19 Feb 2011 23:49:42 +0000 Subject: - Fix spinlocks when table/database deletion causes the table information class to trigger a requery of current state information. This addresses Issue #985. --- Source/SPTableData.m | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Source/SPTableData.m') diff --git a/Source/SPTableData.m b/Source/SPTableData.m index c63d10ff..7ae8f563 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -387,7 +387,11 @@ tableData = [self informationForTable:[tableListInstance tableName]]; } + // If nil is returned, return failure. if (tableData == nil ) { + + // The table information fetch may have already unlocked the data lock. + pthread_mutex_trylock(&dataProcessingLock); pthread_mutex_unlock(&dataProcessingLock); return FALSE; } @@ -487,8 +491,13 @@ nil, nil, [NSApp mainWindow], self, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), tableName, [mySQLConnection getLastErrorMessage]]); + // If the current table doesn't exist anymore reload table list if([mySQLConnection getLastErrorID] == 1146) { + + // Release the table loading lock to allow reselection/reloading to requery the database. + pthread_mutex_unlock(&dataProcessingLock); + [[tableListInstance valueForKeyPath:@"tablesListView"] deselectAll:nil]; [tableListInstance updateTables:self]; } -- cgit v1.2.3