aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-01 23:54:10 +0000
committerrowanbeentje <rowan@beent.je>2009-11-01 23:54:10 +0000
commit7db6c4e18fb52c2e5ada02ad108ab6415a49843d (patch)
tree4b0af2b28ee1e8022928fd556834d6a760d841b1 /Source/CustomQuery.m
parentb5b5b411b5a8adf460ddd5ba7db03d429d7f2a8e (diff)
downloadsequelpro-7db6c4e18fb52c2e5ada02ad108ab6415a49843d.tar.gz
sequelpro-7db6c4e18fb52c2e5ada02ad108ab6415a49843d.tar.bz2
sequelpro-7db6c4e18fb52c2e5ada02ad108ab6415a49843d.zip
- Tweak connection locking to avoid occasional NSLock warnings when running custom queries
- Add error connection to query reselection to avoid exceptions when editing queries while running them
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m21
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index b9896a28..25c90dba 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -81,15 +81,20 @@
- (void) runAllQueriesCallback
{
- // If no error was selected reconstruct a given selection
- if([textView selectedRange].length == 0)
- [textView setSelectedRange:oldThreadedQueryRange];
+ // If no error was selected, reconstruct a given selection. This
+ // may no longer be valid if the query text has changed in the
+ // meantime, so error-checking is required.
+ if (oldThreadedQueryRange.location + oldThreadedQueryRange.length <= [[textView string] length]) {
- // Invoke textStorageDidProcessEditing: for syntax highlighting and auto-uppercase
- NSRange oldRange = [textView selectedRange];
- [textView setSelectedRange:NSMakeRange(oldThreadedQueryRange.location,0)];
- [textView insertText:@""];
- [textView setSelectedRange:oldRange];
+ if ([textView selectedRange].length == 0)
+ [textView setSelectedRange:oldThreadedQueryRange];
+
+ // Invoke textStorageDidProcessEditing: for syntax highlighting and auto-uppercase
+ NSRange oldRange = [textView selectedRange];
+ [textView setSelectedRange:NSMakeRange(oldThreadedQueryRange.location,0)];
+ [textView insertText:@""];
+ [textView setSelectedRange:oldRange];
+ }
}
/*