aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-05-28 23:25:39 +0000
committerstuconnolly <stuart02@gmail.com>2010-05-28 23:25:39 +0000
commitc1fec673e9368eff4527a776bb2b09b777f5864a (patch)
tree299e27e425c658e96c90770edc1f71ac208bf5cf /Source
parentfa3e5de72829b2458c6966b1cad3c99d62401a49 (diff)
downloadsequelpro-c1fec673e9368eff4527a776bb2b09b777f5864a.tar.gz
sequelpro-c1fec673e9368eff4527a776bb2b09b777f5864a.tar.bz2
sequelpro-c1fec673e9368eff4527a776bb2b09b777f5864a.zip
Prevent spawning multiple threads for refreshing the server process list by tracking the threads running state. Fixes log http://spbug.com/l/563.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPProcessListController.h2
-rw-r--r--Source/SPProcessListController.m11
2 files changed, 12 insertions, 1 deletions
diff --git a/Source/SPProcessListController.h b/Source/SPProcessListController.h
index be095d40..298a2e48 100644
--- a/Source/SPProcessListController.h
+++ b/Source/SPProcessListController.h
@@ -30,7 +30,7 @@
{
MCPConnection *connection;
- BOOL showFullProcessList;
+ BOOL showFullProcessList, processListThreadRunning;
NSTimer *autoRefreshTimer;
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]];