From 79cce61253647cf934c292ae7c32c133c4cff51e Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 24 Aug 2020 00:47:42 +0000 Subject: Test branch for AppleScript bugs with patch from Lars Helstrom --- library/tk.tcl | 2 ++ macosx/tkMacOSXHLEvents.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/library/tk.tcl b/library/tk.tcl index 421bac8..abe34ab 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -687,9 +687,11 @@ if {[tk windowingsystem] eq "aqua"} { if {[tk windowingsystem] eq "aqua"} { #stub procedures to respond to "do script" Apple Events proc ::tk::mac::DoScriptFile {file} { + uplevel #0 $file source $file } proc ::tk::mac::DoScriptText {script} { + uplevel #0 $script eval $script } } diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index d15abde..91d7b72 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -309,6 +309,7 @@ static const char *scriptTextProc = "::tk::mac::DoScriptText"; if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, data, actual, NULL)) { + data[actual] = '\0'; AppleEventInfo *AEInfo = ckalloc(sizeof(AppleEventInfo)); Tcl_DString *scriptTextCommand = &AEInfo->command; Tcl_DStringInit(scriptTextCommand); @@ -383,9 +384,6 @@ static void ProcessAppleEvent( } code = Tcl_EvalEx(AEInfo->interp, Tcl_DStringValue(&AEInfo->command), Tcl_DStringLength(&AEInfo->command), TCL_EVAL_GLOBAL); - if (code != TCL_OK) { - Tcl_BackgroundException(AEInfo->interp, code); - } if (AEInfo->replyEvent && code >= 0) { int reslen; @@ -400,7 +398,10 @@ static void ProcessAppleEvent( AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc], keyErrorNumber, typeSInt32, (Ptr) &code, sizeof(int)); } + } else if (code != TCL_OK) { + Tcl_BackgroundException(AEInfo->interp, code); } + Tcl_DStringFree(&AEInfo->command); ckfree(clientData); } -- cgit v0.12