mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Ensure vim controllers are released in default run loop mode
Vim controllers are released when NSConnectionDidDieNotification is received. This notification can arrive in pretty much any run loop mode so we take care not to act on it until the run loop mode is back to default. Otherwise we run the risk of releasing objects which Cocoa is currently using (e.g. view items) and this leads to crashes.
This commit is contained in:
@@ -570,6 +570,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
|
||||
{
|
||||
//NSLog(@"%s%@", _cmd, controller);
|
||||
|
||||
[controller cleanup];
|
||||
[[controller windowController] close];
|
||||
|
||||
[vimControllers removeObject:controller];
|
||||
|
||||
@@ -1229,12 +1229,19 @@ static int MMReceiveQueueCap = 100;
|
||||
{
|
||||
//NSLog(@"%@ %s%@", [self className], _cmd, notification);
|
||||
|
||||
[self cleanup];
|
||||
|
||||
// NOTE! This causes the call to removeVimController: to be delayed.
|
||||
// NOTE! This notification can arrive at pretty much anytime, e.g. while
|
||||
// the run loop is the 'event tracking' mode. This means that Cocoa may
|
||||
// well be in the middle of processing some message while this message is
|
||||
// received. If we were to remove the vim controller straight away we may
|
||||
// free objects that Cocoa is currently using (e.g. view objects). The
|
||||
// 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];
|
||||
withObject:self
|
||||
waitUntilDone:NO
|
||||
modes:[NSArray arrayWithObject:
|
||||
NSDefaultRunLoopMode]];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
|
||||
Reference in New Issue
Block a user