From 7db6c4e18fb52c2e5ada02ad108ab6415a49843d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 1 Nov 2009 23:54:10 +0000 Subject: - 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 --- Source/CustomQuery.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Source') 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]; + } } /* -- cgit v1.2.3