From 521c78fc8e87734c8bdf7a30024ba51c3ec1a306 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 17 Dec 2010 12:33:21 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20timing=20behaviour=20for=20a=20S?= =?UTF-8?q?PDatabaseDocument=20if=20it=20receives=20a=20sequence=20of=20UR?= =?UTF-8?q?L=20scheme=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDatabaseDocument.h | 2 ++ Source/SPDatabaseDocument.m | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index fd716668..bcd92d59 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -163,6 +163,8 @@ NSInteger _queryMode; BOOL _isSavedInBundle; + BOOL _workingTimeout; + NSWindow *taskProgressWindow; BOOL taskDisplayIsIndeterminate; CGFloat taskProgressValue; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index a66d0f42..0c2b7de7 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -4633,6 +4633,11 @@ YY_BUFFER_STATE yy_scan_string (const char *); } +- (void)setTimeout +{ + _workingTimeout = YES; +} + - (void)handleSchemeCommand:(NSDictionary*)commandDict { @@ -4643,11 +4648,19 @@ YY_BUFFER_STATE yy_scan_string (const char *); NSString *docProcessID = [self processID]; if(!docProcessID) docProcessID = @""; - // Bail if document is busy - if (_isWorkingLevel) { - [SPTooltip showWithObject:NSLocalizedString(@"Connection window is busy. URL scheme command bailed", @"Connection window is busy. URL scheme command bailed") atLocation:[NSApp mouseLocation]]; - NSBeep(); - return; + // Wait for self + _workingTimeout = NO; + // the following while loop waits maximal 5secs + [self performSelector:@selector(setTimeout) withObject:nil afterDelay:5.0]; + while (_isWorkingLevel || !_isConnected) { + if(_workingTimeout) break; + // Do not block self + NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if(event) [NSApp sendEvent:event]; + } if([command isEqualToString:@"SelectDocumentView"]) { -- cgit v1.2.3