diff options
author | stuconnolly <stuart02@gmail.com> | 2010-09-26 20:18:01 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-09-26 20:18:01 +0000 |
commit | 15a9a678170c20671e86c5fa18393e1c5bddaff4 (patch) | |
tree | 2dcce2c9beebd56f84a101fac3d8de27ff285f42 /Source | |
parent | 9205ee00ec0d9be788db6c54ed0ca9eba3735b9a (diff) | |
download | sequelpro-15a9a678170c20671e86c5fa18393e1c5bddaff4.tar.gz sequelpro-15a9a678170c20671e86c5fa18393e1c5bddaff4.tar.bz2 sequelpro-15a9a678170c20671e86c5fa18393e1c5bddaff4.zip |
Implement threading locking when modifying the query console/controller's log data storage to prevent race conditions. Should fix crash: http://spbug.com/l/1644
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPQueryController.h | 2 | ||||
-rw-r--r-- | Source/SPQueryController.m | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h index 797d5b6b..9c8a9c8f 100644 --- a/Source/SPQueryController.h +++ b/Source/SPQueryController.h @@ -57,6 +57,8 @@ NSUserDefaults *prefs; NSDateFormatter *dateFormatter; + + pthread_mutex_t consoleLock; } @property (readwrite, retain) NSFont *consoleFont; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index eb0e8a1a..ec7e6b70 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -29,6 +29,8 @@ #import "SPConstants.h" #import "SPCustomQuery.h" +#import "pthread.h" + #define MESSAGE_TRUNCATE_CHARACTER_LENGTH 256 // Table view column identifiers @@ -96,6 +98,8 @@ static SPQueryController *sharedQueryController = nil; completionKeywordList = nil; completionFunctionList = nil; functionArgumentSnippets = nil; + + pthread_mutex_init(&consoleLock, NULL); NSError *readError = nil; NSString *convError = nil; @@ -824,6 +828,9 @@ static SPQueryController *sharedQueryController = nil; if(completionKeywordList) [completionKeywordList release]; if(completionFunctionList) [completionFunctionList release]; if(functionArgumentSnippets) [functionArgumentSnippets release]; + + pthread_mutex_destroy(&consoleLock); + [super dealloc]; } @@ -981,6 +988,8 @@ static SPQueryController *sharedQueryController = nil; [consoleMessage setIsError:error]; + pthread_mutex_lock(&consoleLock); + [messagesFullSet addObject:consoleMessage]; // If filtering is active, determine whether to add a reference to the filtered set @@ -998,6 +1007,8 @@ static SPQueryController *sharedQueryController = nil; [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; [consoleTableView reloadData]; } + + pthread_mutex_unlock(&consoleLock); } @end |