From 3915c6afc69b1e57ced7adb50f62b81079d23ae0 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Fri, 6 Jun 2008 14:22:49 +0200 Subject: [PATCH] Catch exceptions in processCommandQueue: --- src/MacVim/MMVimController.m | 45 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index e27ee3ffcf..60690beec1 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -525,28 +525,33 @@ static NSTimeInterval MMResendInterval = 0.5; { if (!isInitialized) return; - unsigned i, count = [queue count]; - if (count % 2) { - NSLog(@"WARNING: Uneven number of components (%d) in flush queue " - "message; ignoring this message.", count); - return; + @try { + unsigned i, count = [queue count]; + if (count % 2) { + NSLog(@"WARNING: Uneven number of components (%d) in flush queue " + "message; ignoring this message.", count); + return; + } + + inProcessCommandQueue = YES; + + //NSLog(@"======== %s BEGIN ========", _cmd); + for (i = 0; i < count; i += 2) { + NSData *value = [queue objectAtIndex:i]; + NSData *data = [queue objectAtIndex:i+1]; + + int msgid = *((int*)[value bytes]); + //NSLog(@"%s%s", _cmd, MessageStrings[msgid]); + + [self handleMessage:msgid data:data]; + } + //NSLog(@"======== %s END ========", _cmd); + + [windowController processCommandQueueDidFinish]; } - - inProcessCommandQueue = YES; - - //NSLog(@"======== %s BEGIN ========", _cmd); - for (i = 0; i < count; i += 2) { - NSData *value = [queue objectAtIndex:i]; - NSData *data = [queue objectAtIndex:i+1]; - - int msgid = *((int*)[value bytes]); - //NSLog(@"%s%s", _cmd, MessageStrings[msgid]); - - [self handleMessage:msgid data:data]; + @catch (NSException *e) { + NSLog(@"Exception caught whilst processing command queue: %@", e); } - //NSLog(@"======== %s END ========", _cmd); - - [windowController processCommandQueueDidFinish]; inProcessCommandQueue = NO;