Permalink
Browse files

Delay display of popup menu

The popup menu enters a modal loop so it is not displayed immediately to
avoid blocking inside processCommandQueue:.
  • Loading branch information...
1 parent d98996d commit e7b9c110896b5c6c75445c7a6655e7c3b23b9d4c @b4winckler committed Jun 21, 2008
Showing with 18 additions and 3 deletions.
  1. +18 −3 src/MacVim/MMVimController.m
@@ -87,6 +87,7 @@ - (void)addToolbarItemWithLabel:(NSString *)label
- (void)popupMenuWithDescriptor:(NSArray *)desc
atRow:(NSNumber *)row
column:(NSNumber *)col;
+- (void)popupMenuWithAttributes:(NSDictionary *)attrs;
- (void)connectionDidDie:(NSNotification *)notification;
@end
@@ -804,9 +805,14 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
[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 @@ - (void)popupMenuWithDescriptor:(NSArray *)desc
[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);

0 comments on commit e7b9c11

Please sign in to comment.