diff options
author | rowanbeentje <rowan@beent.je> | 2009-11-01 23:54:10 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-11-01 23:54:10 +0000 |
commit | 7db6c4e18fb52c2e5ada02ad108ab6415a49843d (patch) | |
tree | 4b0af2b28ee1e8022928fd556834d6a760d841b1 /Source | |
parent | b5b5b411b5a8adf460ddd5ba7db03d429d7f2a8e (diff) | |
download | sequelpro-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')
-rw-r--r-- | Source/CustomQuery.m | 21 |
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]; + } } /* |