summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2020-10-17 17:31:40 (GMT)
committermarc_culler <marc.culler@gmail.com>2020-10-17 17:31:40 (GMT)
commit2a92717a443e8caee17f51dae951666b9191d803 (patch)
treed66431cd2bf699b6dfa22b8c276c71190e14e7a6 /macosx/tkMacOSXInit.c
parenteae4e5cd7ead346d5ed79e6269c554becd5f8099 (diff)
downloadtk-2a92717a443e8caee17f51dae951666b9191d803.zip
tk-2a92717a443e8caee17f51dae951666b9191d803.tar.gz
tk-2a92717a443e8caee17f51dae951666b9191d803.tar.bz2
Small adjustment to d69b5cec: make sure Tcl_Finalize *always* gets called.
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index e895cc0..c7ee971 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -298,7 +298,20 @@ TCL_NORETURN void TkMacOSXExitProc(
ClientData clientdata)
{
closePanels();
- [(TKApplication *)NSApp superTerminate:nil]; /* Does not return. */
+
+ /*
+ * Make sure we don't get called again. This can happen, e.g. with
+ * fossil diff -tk.
+ */
+
+ Tcl_SetExitProc(NULL);
+
+ /*
+ * Tcl_Exit does not call Tcl_Finalize if there is an exit proc installed.
+ */
+
+ Tcl_Finalize();
+ [(TKApplication *)NSApp superTerminate:nil]; /* Should not return. */
exit((int)clientdata); /* Convince the compiler that we don't return. */
}
@@ -430,6 +443,7 @@ TkpInit(
Tcl_SetVar2(interp, "tcl_interactive", NULL, "1",
TCL_GLOBAL_ONLY);
}
+ isLaunched = YES;
shouldOpenConsole = YES;
}
if (shouldOpenConsole) {
@@ -494,13 +508,16 @@ TkpInit(
* calling [NSApplication terminate]. This does not work correctly if
* the process is part of an exec pipeline, so it is only used if the
* process was launched by the launcher or if both stdin and stdout are
- * ttys.
+ * ttys. If an exit proc was already installed we leave it in place.
*/
# if !defined(USE_SYSTEM_EXIT)
if (isLaunched || (isatty(0) && isatty(1))) {
- Tcl_SetExitProc(TkMacOSXExitProc);
+ Tcl_ExitProc *prevExitProc = Tcl_SetExitProc(TkMacOSXExitProc);
+ if (prevExitProc) {
+ Tcl_SetExitProc(prevExitProc);
+ }
}
# endif