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:
Bjorn Winckler
2008-06-20 19:33:34 +02:00
parent 9ca5f6bcdb
commit 59ad683558
2 changed files with 12 additions and 4 deletions
+1
View File
@@ -570,6 +570,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
{
//NSLog(@"%s%@", _cmd, controller);
[controller cleanup];
[[controller windowController] close];
[vimControllers removeObject:controller];
+11 -4
View File
@@ -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