summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordavygrvy <davygrvy>2003-12-21 23:50:13 (GMT)
committerdavygrvy <davygrvy>2003-12-21 23:50:13 (GMT)
commitbd23cfcf8912fb898bef69b10cd34e3673d0af83 (patch)
tree0dd59c8ef95660d1afe7967786a7a4fd4f6bdedd /win
parent747881c8033dd9bcecd061f4c5d75f5bdc6097c5 (diff)
downloadtk-bd23cfcf8912fb898bef69b10cd34e3673d0af83.zip
tk-bd23cfcf8912fb898bef69b10cd34e3673d0af83.tar.gz
tk-bd23cfcf8912fb898bef69b10cd34e3673d0af83.tar.bz2
* generic/tkEvent.c: Added three new functions: TkCreateExitHandler,
* generic/tkInt.h: TkDeleteExitHandler, and TkFinalize. This adds * generic/tkMenu.c: an insertion point so Tk's exit handlers can be * generic/tkWindow.c: called on their own from tk85.dll's DllMain * mac/tkMacButton.c: for DLL_PROCESS_DETACH. These are private to * unix/tkUnixEvent.c: the binary and not exported. It is possible * win/tkWin32Dll.c: the Windows OS can unload Tk _prior_ to Tcl * win/tkWinEmbed.c: under some conditions such as ExitProcess(). * win/tkWinMenu.c: This avoids a dangling pointer problem when Tcl * win/tkWinX.c: does Tcl_Finalize after Tk has been unloaded. * win/winMain.c: DllMain's DLL_PROCESS_DETACH now protected with SEH as DeleteWindowsExitProc is causing an exception of its own under some teardown conditions. AT&T assembly syntax has not been added for MinGW yet. [Tcl Patch 858493]
Diffstat (limited to 'win')
-rw-r--r--win/tkWin32Dll.c37
-rw-r--r--win/tkWinEmbed.c6
-rw-r--r--win/tkWinMenu.c4
-rw-r--r--win/tkWinX.c4
-rw-r--r--win/winMain.c4
5 files changed, 42 insertions, 13 deletions
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 4570a5a..f5aa7ed 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -8,10 +8,11 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin32Dll.c,v 1.6 2002/12/08 00:46:51 hobbs Exp $
+ * RCS: @(#) $Id: tkWin32Dll.c,v 1.7 2003/12/21 23:50:13 davygrvy Exp $
*/
#include "tkWinInt.h"
+#ifndef STATIC_BUILD
/*
* The following declaration is for the VC++ DLL entry point.
@@ -61,7 +62,9 @@ DllEntryPoint(hInst, reason, reserved)
* Always TRUE.
*
* Side effects:
- * None.
+ * This might call some sycronization functions, but MSDN
+ * documentation states: "Waiting on synchronization objects in
+ * DllMain can cause a deadlock."
*
*----------------------------------------------------------------------
*/
@@ -77,8 +80,34 @@ DllMain(hInstance, reason, reserved)
* the hInstance to use.
*/
- if (reason == DLL_PROCESS_ATTACH) {
+ switch (reason) {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hInstance);
TkWinSetHINSTANCE(hInstance);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ /*
+ * Protect the call to TkFinalize in an SEH block. We can't
+ * be guarenteed Tk is always being unloaded from a stable
+ * condition.
+ */
+
+ __try {
+ /*
+ * Run and remove our exit handlers, if they haven't already
+ * been run. Just in case we are being unloaded prior to
+ * Tcl (it can happen), we won't leave any dangling pointers
+ * hanging around for when Tcl gets unloaded later.
+ */
+
+ TkFinalize(NULL);
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ /* empty handler body */
+ }
+ break;
}
- return (TRUE);
+ return TRUE;
}
+#endif /* !STATIC_BUILD */
+
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index 19d4506..62ffbb3 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinEmbed.c,v 1.8 2003/12/13 01:07:35 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinEmbed.c,v 1.9 2003/12/21 23:50:13 davygrvy Exp $
*/
#include "tkWinInt.h"
@@ -208,7 +208,7 @@ TkpUseWindow(interp, tkwin, string)
*/
if (tsdPtr->firstContainerPtr == (Container *) NULL) {
- Tcl_CreateExitHandler(CleanupContainerList, (ClientData) NULL);
+ TkCreateExitHandler(CleanupContainerList, (ClientData) NULL);
}
/*
@@ -284,7 +284,7 @@ TkpMakeContainer(tkwin)
*/
if (tsdPtr->firstContainerPtr == (Container *) NULL) {
- Tcl_CreateExitHandler(CleanupContainerList, (ClientData) NULL);
+ TkCreateExitHandler(CleanupContainerList, (ClientData) NULL);
}
/*
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index bf8c2d4..f366cf7 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinMenu.c,v 1.25 2003/12/16 03:12:51 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinMenu.c,v 1.26 2003/12/21 23:50:13 davygrvy Exp $
*/
#define OEMRESOURCE
@@ -2990,7 +2990,7 @@ TkpMenuInit()
tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, "MenuWindow", WS_POPUP,
0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL);
- Tcl_CreateExitHandler(MenuExitHandler, (ClientData) NULL);
+ TkCreateExitHandler(MenuExitHandler, (ClientData) NULL);
SetDefaults(1);
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 6a1e292..8a4fe05 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.26 2003/12/13 01:50:29 davygrvy Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.27 2003/12/21 23:50:13 davygrvy Exp $
*/
#include "tkWinInt.h"
@@ -277,7 +277,7 @@ TkWinXInit(hInstance)
/*
* Make sure we cleanup on finalize.
*/
- Tcl_CreateExitHandler((Tcl_ExitProc *) TkWinXCleanup,
+ TkCreateExitHandler((Tcl_ExitProc *) TkWinXCleanup,
(ClientData) hInstance);
}
diff --git a/win/winMain.c b/win/winMain.c
index ba203c4..84fe4f9 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: winMain.c,v 1.18 2003/12/12 00:45:33 davygrvy Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.19 2003/12/21 23:50:13 davygrvy Exp $
*/
#include <tk.h>
@@ -174,7 +174,7 @@ Tcl_AppInit(interp)
* This exit handler will be used to free the
* resources allocated in this file.
*/
- Tcl_CreateExitHandler(AppInitExitHandler, NULL);
+ TkCreateExitHandler(AppInitExitHandler, NULL);
/*
* Initialize the console only if we are running as an interactive