summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordavygrvy <davygrvy>2004-10-27 00:37:37 (GMT)
committerdavygrvy <davygrvy>2004-10-27 00:37:37 (GMT)
commitd33aaf2b8fa569171d30a455a154d803d2ecb5c6 (patch)
treeb983c1273c1a6326de84746006f8e4f502466cdb /win
parent5272d0523a6a8fba692f9407882c5d159db3c3ff (diff)
downloadtk-d33aaf2b8fa569171d30a455a154d803d2ecb5c6.zip
tk-d33aaf2b8fa569171d30a455a154d803d2ecb5c6.tar.gz
tk-d33aaf2b8fa569171d30a455a154d803d2ecb5c6.tar.bz2
* generic/tkInt.h: Backport of shutdown safety mods from the HEAD
* generic/tkMenu.c: dating from 2003-12-21 * generic/tkUtil.c: * generic/tkWindow.c: * mac/tkMacButton.c: * unix/tkUnixEvent.c: * win/tkWin32Dll.c: * win/tkWinEmbed.c: * win/tkWinMenu.c: * win/tkWinX.c:
Diffstat (limited to 'win')
-rw-r--r--win/tkWin32Dll.c42
-rw-r--r--win/tkWinEmbed.c16
-rw-r--r--win/tkWinMenu.c4
-rw-r--r--win/tkWinX.c10
4 files changed, 51 insertions, 21 deletions
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 4570a5a..fde647b 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -8,16 +8,17 @@
* 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.6.2.1 2004/10/27 00:37:38 davygrvy Exp $
*/
#include "tkWinInt.h"
+#ifndef STATIC_BUILD
/*
* The following declaration is for the VC++ DLL entry point.
*/
-BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
+BOOL WINAPI DllMain _ANSI_ARGS_((HINSTANCE hInst,
DWORD reason, LPVOID reserved));
/*
@@ -38,7 +39,7 @@ BOOL APIENTRY DllMain _ANSI_ARGS_((HINSTANCE hInst,
*----------------------------------------------------------------------
*/
-BOOL APIENTRY
+BOOL WINAPI
DllEntryPoint(hInst, reason, reserved)
HINSTANCE hInst; /* Library instance handle. */
DWORD reason; /* Reason this function is being called. */
@@ -61,12 +62,14 @@ 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."
*
*----------------------------------------------------------------------
*/
-BOOL APIENTRY
+BOOL WINAPI
DllMain(hInstance, reason, reserved)
HINSTANCE hInstance;
DWORD reason;
@@ -77,8 +80,33 @@ 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 990ff29..a916050 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.7 2002/08/05 04:30:41 dgp Exp $
+ * RCS: @(#) $Id: tkWinEmbed.c,v 1.7.2.1 2004/10/27 00:37:38 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);
}
/*
@@ -385,11 +385,13 @@ TkWinEmbeddedEventProc(hwnd, message, wParam, lParam)
*/
for (containerPtr = tsdPtr->firstContainerPtr;
- containerPtr->parentHWnd != hwnd;
+ containerPtr && containerPtr->parentHWnd != hwnd;
containerPtr = containerPtr->nextPtr) {
- if (containerPtr == NULL) {
- panic("TkWinContainerProc couldn't find Container record");
- }
+ /* empty loop body */
+ }
+
+ if (containerPtr == NULL) {
+ Tcl_Panic("TkWinContainerProc couldn't find Container record");
}
switch (message) {
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 8dec5d8..b101ab6 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.21.2.3 2004/09/23 00:56:15 mdejong Exp $
+ * RCS: @(#) $Id: tkWinMenu.c,v 1.21.2.4 2004/10/27 00:37:38 davygrvy Exp $
*/
#define OEMRESOURCE
@@ -3014,7 +3014,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 da65e26..7ca4ad5 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.25.2.4 2004/09/23 01:49:08 hobbs Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.25.2.5 2004/10/27 00:37:38 davygrvy Exp $
*/
#include "tkWinInt.h"
@@ -283,8 +283,7 @@ TkWinXInit(hInstance)
/*
* Make sure we cleanup on finalize.
*/
- Tcl_CreateExitHandler((Tcl_ExitProc *) TkWinXCleanup,
- (ClientData) hInstance);
+ TkCreateExitHandler(TkWinXCleanup, (ClientData) hInstance);
}
/*
@@ -304,9 +303,10 @@ TkWinXInit(hInstance)
*/
void
-TkWinXCleanup(hInstance)
- HINSTANCE hInstance;
+TkWinXCleanup(clientData)
+ ClientData clientData;
{
+ HINSTANCE hInstance = (HINSTANCE) clientData;
/*
* Clean up our own class.
*/