2011-09-05 41 views
0

我在控制檯收到此錯誤從SIMBLAppleEvent:如何調試eventDidFail?

05.09.11 17:00:09,165 SIMBL Agent: eventDidFail:'tvea' error:Error Domain=NSOSStatusErrorDomain Code=-1708 "The operation couldn’t be completed. (OSStatus error -1708.)" (the AppleEvent was not handled by any handler) UserInfo=0x400e485c0 {ErrorNumber=-1708} userInfo:{ 
    ErrorNumber = "-1708"; 
} 

我想這調試;但由於我還沒有真正與AppleEvent合作過,所以我不太確定如何解釋這一點。

我認爲在SIMBL代理相關的代碼是這樣的:

AEEventID eventID = 'load'; 

// Find the process to target 
pid_t pid = [[appInfo objectForKey:@"NSApplicationProcessIdentifier"] intValue]; 
SBApplication* app = [SBApplication applicationWithProcessIdentifier:pid]; 
[app setDelegate:self]; 
if (!app) { 
    SIMBLLogNotice(@"Can't find app with pid %d", pid); 
    return; 
} 

// Force AppleScript to initialize in the app, by getting the dictionary 
// When initializing, you need to wait for the event reply, otherwise the 
// event might get dropped on the floor. This is only seems to happen in 10.5 
// but it shouldn't harm anything. 
[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord]; 
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0]; 

// the reply here is of some unknown type - it is not an Objective-C object 
// as near as I can tell because trying to print it using "%@" or getting its 
// class both cause the application to segfault. The pointer value always seems 
// to be 0x10000 which is a bit fishy. It does not seem to be an AEDesc struct 
// either. 
// since we are waiting for a reply, it seems like this object might need to 
// be released - but i don't know what it is or how to release it. 
// NSLog(@"initReply: %p '%64.64s'", initReply, (char*)initReply); 

// Inject! 
[app setSendMode:kAENoReply | kAENeverInteract | kAEDontRecord]; 
id injectReply = [app sendEvent:'SIMe' id:eventID parameters:0]; 
if (injectReply != nil) { 
    SIMBLLogNotice(@"unexpected injectReply: %@", injectReply); 
} 

回答

0

eventDidFail消息還來自於SIMBL代理本身。正是這種代碼:

- (void) eventDidFail:(const AppleEvent*)event withError:(NSError*)error 
{ 
    NSDictionary* userInfo = [error userInfo]; 
    NSNumber* errorNumber = [userInfo objectForKey:@"ErrorNumber"]; 

    // this error seems more common on Leopard 
    if (errorNumber && [errorNumber intValue] == errAEEventNotHandled) { 
     SIMBLLogDebug(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]); 
    } 
    else { 
     SIMBLLogNotice(@"eventDidFail:'%4.4s' error:%@ userInfo:%@", (char*)&(event->descriptorType), error, [error userInfo]); 
    } 
} 

如果我註釋掉的代碼錯誤消失:

[app setSendMode:kAEWaitReply | kAENeverInteract | kAEDontRecord]; 
id initReply = [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0]; 
+0

你應該修改你原來的問題,這不是一個回答你的問題,僅僅是附加信息。 – uvesten

+0

@uvesten:不是嗎?我確定了失敗的命令。我也發現了錯誤的代碼。因此我調試了這個問題,所有的信息都在這個答案中。 – Albert

+0

好的,我的壞。我認爲這更多的是解決問題的辦法,而不是爲什麼它失敗。我現在會保持安靜。 – uvesten