From c1fec673e9368eff4527a776bb2b09b777f5864a Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Fri, 28 May 2010 23:25:39 +0000 Subject: Prevent spawning multiple threads for refreshing the server process list by tracking the threads running state. Fixes log http://spbug.com/l/563. --- Source/SPProcessListController.m | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Source/SPProcessListController.m') diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index 34405701..a46c5d0d 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -61,6 +61,8 @@ if ((self = [super initWithWindowNibName:@"DatabaseProcessList"])) { autoRefreshTimer = nil; + processListThreadRunning = NO; + processes = [[NSMutableArray alloc] init]; prefs = [NSUserDefaults standardUserDefaults]; @@ -185,6 +187,9 @@ // allow a refresh to prevent connection lock errors. if ([(SPDatabaseDocument *)[connection delegate] isWorking]) return; + // Also, only proceed if there is not already a background thread running. + if (processListThreadRunning) return; + // Start progress Indicator [refreshProgressIndicator startAnimation:self]; [refreshProgressIndicator setHidden:NO]; @@ -193,6 +198,8 @@ [refreshProcessesButton setEnabled:NO]; [saveProcessesButton setEnabled:NO]; [filterProcessesSearchField setEnabled:NO]; + + processListThreadRunning = YES; // Get the processes list on a background thread [NSThread detachNewThreadSelector:@selector(_getDatabaseProcessListInBackground:) toTarget:self withObject:nil]; @@ -508,6 +515,8 @@ { [prefs removeObserver:self forKeyPath:SPUseMonospacedFonts]; + processListThreadRunning = NO; + [processes release], processes = nil; if (autoRefreshTimer) [autoRefreshTimer release], autoRefreshTimer = nil; @@ -523,6 +532,8 @@ */ - (void)_processListRefreshed { + processListThreadRunning = NO; + // Reapply any filters is required if ([[filterProcessesSearchField stringValue] length] > 0) { [self _updateServerProcessesFilterForFilterString:[filterProcessesSearchField stringValue]]; -- cgit v1.2.3