diff options
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r-- | macosx/tkMacOSXHLEvents.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 9671ab9..daf860f 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -51,15 +51,15 @@ static OSStatus FSRefToDString(const FSRef *fsref, Tcl_DString *ds); #pragma mark TKApplication(TKHLEvents) @implementation TKApplication(TKHLEvents) - -- (void)terminate:(id)sender { +- (void) terminate: (id) sender +{ QuitHandler(NULL, NULL, (SRefCon) _eventInterp); } -- (void)preferences:(id)sender { +- (void) preferences: (id) sender +{ PrefsHandler(NULL, NULL, (SRefCon) _eventInterp); } - @end #pragma mark - @@ -186,7 +186,7 @@ QuitHandler( * quickly as possible. */ - eventPtr = (KillEvent *) ckalloc(sizeof(KillEvent)); + eventPtr = ckalloc(sizeof(KillEvent)); eventPtr->header.proc = ReallyKillMe; eventPtr->interp = interp; @@ -217,14 +217,13 @@ OappHandler( AppleEvent *reply, SRefCon handlerRefcon) { - Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && - Tcl_GetCommandInfo(interp, "::tk::mac::OpenApplication", &dummy)){ + Tcl_FindCommand(interp, "::tk::mac::OpenApplication", NULL, 0)){ int code = Tcl_EvalEx(interp, "::tk::mac::OpenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } } return noErr; @@ -252,16 +251,15 @@ RappHandler( AppleEvent *reply, SRefCon handlerRefcon) { - Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; ProcessSerialNumber thePSN = {0, kCurrentProcess}; OSStatus err = ChkErr(SetFrontProcess, &thePSN); - if (interp && Tcl_GetCommandInfo(interp, - "::tk::mac::ReopenApplication", &dummy)) { + if (interp && Tcl_FindCommand(interp, + "::tk::mac::ReopenApplication", NULL, 0)) { int code = Tcl_EvalEx(interp, "::tk::mac::ReopenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK){ - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } } return err; @@ -290,14 +288,13 @@ PrefsHandler( AppleEvent *reply, SRefCon handlerRefcon) { - Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && - Tcl_GetCommandInfo(interp, "::tk::mac::ShowPreferences", &dummy)){ + Tcl_FindCommand(interp, "::tk::mac::ShowPreferences", NULL, 0)){ int code = Tcl_EvalEx(interp, "::tk::mac::ShowPreferences", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } } return noErr; @@ -333,7 +330,6 @@ OdocHandler( long count, index; AEKeyword keyword; Tcl_DString command, pathName; - Tcl_CmdInfo dummy; int code; /* @@ -342,7 +338,7 @@ OdocHandler( */ if (!interp || - !Tcl_GetCommandInfo(interp, "::tk::mac::OpenDocument", &dummy)) { + !Tcl_FindCommand(interp, "::tk::mac::OpenDocument", NULL, 0)) { return noErr; } @@ -388,7 +384,7 @@ OdocHandler( code = Tcl_EvalEx(interp, Tcl_DStringValue(&command), Tcl_DStringLength(&command), TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } Tcl_DStringFree(&command); return noErr; @@ -424,7 +420,6 @@ PrintHandler( long count, index; AEKeyword keyword; Tcl_DString command, pathName; - Tcl_CmdInfo dummy; int code; /* @@ -433,7 +428,7 @@ PrintHandler( */ if (!interp || - !Tcl_GetCommandInfo(interp, "::tk::mac::PrintDocument", &dummy)) { + !Tcl_FindCommand(interp, "::tk::mac::PrintDocument", NULL, 0)) { return noErr; } @@ -474,7 +469,7 @@ PrintHandler( code = Tcl_EvalEx(interp, Tcl_DStringValue(&command), Tcl_DStringLength(&command), TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } Tcl_DStringFree(&command); return noErr; @@ -545,8 +540,12 @@ ScriptHandler( theErr = FSRefToDString(&file, &scriptName); if (theErr == noErr) { - tclErr = Tcl_EvalFile(interp, Tcl_DStringValue(&scriptName)); + Tcl_Obj *pathName = + Tcl_NewStringObj(Tcl_DStringValue(&scriptName), -1); Tcl_DStringFree(&scriptName); + + tclErr = Tcl_FSEvalFile(interp, pathName); + Tcl_DecrRefCount(pathName); } else { sprintf(errString, "AEDoScriptHandler: file not found"); AEPutParamPtr(reply, keyErrorString, typeChar, errString, @@ -623,8 +622,7 @@ ReallyKillMe( int flags) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; - Tcl_CmdInfo dummy; - int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy); + int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL; int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { @@ -632,7 +630,7 @@ ReallyKillMe( * Should be never reached... */ - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } return 1; } |