From bee0d6b191d83d378f35eee0699c846f451f7dd8 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 21 Jun 2008 21:23:30 +0200 Subject: [PATCH] Delay display of popup menu The popup menu enters a modal loop so it is not displayed immediately to avoid blocking inside processCommandQueue:. --- src/MacVim/MMVimController.m | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index e174fb6a..6a861f03 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -87,6 +87,7 @@ static BOOL isUnsafeMessage(int msgid); - (void)popupMenuWithDescriptor:(NSArray *)desc atRow:(NSNumber *)row column:(NSNumber *)col; +- (void)popupMenuWithAttributes:(NSDictionary *)attrs; - (void)connectionDidDie:(NSNotification *)notification; @end @@ -804,9 +805,14 @@ static BOOL isUnsafeMessage(int msgid); [actionName release]; } else if (ShowPopupMenuMsgID == msgid) { NSDictionary *attrs = [NSDictionary dictionaryWithData:data]; - [self popupMenuWithDescriptor:[attrs objectForKey:@"descriptor"] - atRow:[attrs objectForKey:@"row"] - column:[attrs objectForKey:@"column"]]; + + // The popup menu enters a modal loop so delay this call so that we + // don't block inside processCommandQueue:. + [self performSelectorOnMainThread:@selector(popupMenuWithAttributes:) + withObject:attrs + waitUntilDone:NO + modes:[NSArray arrayWithObject: + NSDefaultRunLoopMode]]; } else if (SetMouseShapeMsgID == msgid) { const void *bytes = [data bytes]; int shape = *((int*)bytes); bytes += sizeof(int); @@ -1272,6 +1278,15 @@ static BOOL isUnsafeMessage(int msgid); [NSMenu popUpContextMenu:menu withEvent:event forView:textView]; } +- (void)popupMenuWithAttributes:(NSDictionary *)attrs +{ + if (!attrs) return; + + [self popupMenuWithDescriptor:[attrs objectForKey:@"descriptor"] + atRow:[attrs objectForKey:@"row"] + column:[attrs objectForKey:@"column"]]; +} + - (void)connectionDidDie:(NSNotification *)notification { //NSLog(@"%@ %s%@", [self className], _cmd, notification); -- 2.11.4.GIT