Skip to content

Commit

Permalink
Deprecate performSelectorOnMainThread calls
Browse files Browse the repository at this point in the history
Use performSelector:withObject:after:delay instead since it
automatically only triggers in default mode.
  • Loading branch information
b4winckler committed Apr 8, 2009
1 parent e93e9c4 commit dd76f85
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/MacVim/MMAppController.m
Expand Up @@ -1123,8 +1123,8 @@ - (unsigned)connectBackend:(byref in id <MMBackendProtocol>)proxy pid:(int)pid
// arrive at unpredictable times (e.g. while iterating the list of vim
// controllers).
// (What if input arrives before the vim controller is added to the list of
// controllers? This is not a problem since the input isn't processed
// immediately (see processInput:forIdentifier:).)
// controllers? This should not be a problem since the input isn't
// processed immediately (see processInput:forIdentifier:).)
MMVimController *vc = [[MMVimController alloc] initWithBackend:proxy
pid:pid];
[self performSelector:@selector(addVimController:)
Expand Down Expand Up @@ -2133,7 +2133,7 @@ - (void)processInputQueues:(id)sender
// not need to worry about it.

// The processing flag is > 0 if this function is already on the call
// stack; < 0 if this function was re-entered.
// stack; < 0 if this function was also re-entered.
if (processingFlag != 0) {
NSLog(@"[%s] BUSY!", _cmd);
processingFlag = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/MacVim/MMBackend.m
Expand Up @@ -2480,9 +2480,9 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
if ([args objectForKey:@"remoteID"]) {
// NOTE: We have to delay processing any ODB related arguments since
// the file(s) may not be opened until the input buffer is processed.
[self performSelectorOnMainThread:@selector(startOdbEditWithArguments:)
withObject:args
waitUntilDone:NO];
[self performSelector:@selector(startOdbEditWithArguments:)
withObject:args
afterDelay:0];
}

NSString *lineString = [args objectForKey:@"cursorLine"];
Expand Down
40 changes: 15 additions & 25 deletions src/MacVim/MMVimController.m
Expand Up @@ -521,11 +521,9 @@ - (void)doProcessInputQueue:(NSArray *)queue

if (delayQueue) {
//NSLog(@" Flushing delay queue (%d items)", [delayQueue count]/2);
[self performSelectorOnMainThread:@selector(processInputQueue:)
withObject:delayQueue
waitUntilDone:NO
modes:[NSArray arrayWithObject:
NSDefaultRunLoopMode]];
[self performSelector:@selector(processInputQueue:)
withObject:delayQueue
afterDelay:0];
}
}

Expand Down Expand Up @@ -722,11 +720,9 @@ - (void)handleMessage:(int)msgid data:(NSData *)data

// The popup menu enters a modal loop so delay this call so that we
// don't block inside processInputQueue:.
[self performSelectorOnMainThread:@selector(popupMenuWithAttributes:)
withObject:attrs
waitUntilDone:NO
modes:[NSArray arrayWithObject:
NSDefaultRunLoopMode]];
[self performSelector:@selector(popupMenuWithAttributes:)
withObject:attrs
afterDelay:0];
} else if (SetMouseShapeMsgID == msgid) {
const void *bytes = [data bytes];
int shape = *((int*)bytes); bytes += sizeof(int);
Expand Down Expand Up @@ -1246,11 +1242,9 @@ - (void)scheduleClose
// following call ensures that the vim controller is not released until the
// run loop is back in the 'default' mode.
[[MMAppController sharedInstance]
performSelectorOnMainThread:@selector(removeVimController:)
withObject:self
waitUntilDone:NO
modes:[NSArray arrayWithObject:
NSDefaultRunLoopMode]];
performSelector:@selector(removeVimController:)
withObject:self
afterDelay:0];
}

- (void)handleBrowseForFile:(NSDictionary *)attr
Expand All @@ -1261,11 +1255,9 @@ - (void)handleBrowseForFile:(NSDictionary *)attr
isEqual:NSDefaultRunLoopMode];
if (!inDefaultMode) {
// Delay call until run loop is in default mode.
[self performSelectorOnMainThread:@selector(handleBrowseForFile:)
withObject:attr
waitUntilDone:NO
modes:[NSArray arrayWithObject:
NSDefaultRunLoopMode]];
[self performSelector:@selector(handleBrowseForFile:)
withObject:attr
afterDelay:0];
return;
}

Expand Down Expand Up @@ -1308,11 +1300,9 @@ - (void)handleShowDialog:(NSDictionary *)attr
isEqual:NSDefaultRunLoopMode];
if (!inDefaultMode) {
// Delay call until run loop is in default mode.
[self performSelectorOnMainThread:@selector(handleShowDialog:)
withObject:attr
waitUntilDone:NO
modes:[NSArray arrayWithObject:
NSDefaultRunLoopMode]];
[self performSelector:@selector(handleShowDialog:)
withObject:attr
afterDelay:0];
return;
}

Expand Down

0 comments on commit dd76f85

Please sign in to comment.