summaryrefslogtreecommitdiffstats
path: root/generic/tkMenu.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-02-26 02:32:55 (GMT)
committerhobbs <hobbs>2003-02-26 02:32:55 (GMT)
commit545636f30356c3701dab3eac90deaf3a87d88c47 (patch)
treea96d39e32fb10e92b487a383610cf76aa3bc3567 /generic/tkMenu.c
parent5878012a935791359f1ea3ccb7f80eba025b3339 (diff)
downloadtk-545636f30356c3701dab3eac90deaf3a87d88c47.zip
tk-545636f30356c3701dab3eac90deaf3a87d88c47.tar.gz
tk-545636f30356c3701dab3eac90deaf3a87d88c47.tar.bz2
* generic/tkMenu.c (TkMenuCleanup): make sure to reset static
menusInitialized on finalize. [Bug #548729]
Diffstat (limited to 'generic/tkMenu.c')
-rw-r--r--generic/tkMenu.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 7ed2d94..152e57f 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMenu.c,v 1.19 2002/08/05 04:30:40 dgp Exp $
+ * RCS: @(#) $Id: tkMenu.c,v 1.20 2003/02/26 02:32:56 hobbs Exp $
*/
/*
@@ -370,6 +370,7 @@ static void MenuWorldChanged _ANSI_ARGS_((
static int PostProcessEntry _ANSI_ARGS_((TkMenuEntry *mePtr));
static void RecursivelyDeleteMenu _ANSI_ARGS_((TkMenu *menuPtr));
static void UnhookCascadeEntry _ANSI_ARGS_((TkMenuEntry *mePtr));
+static void TkMenuCleanup _ANSI_ARGS_((ClientData unused));
/*
* The structure below is a list of procs that respond to certain window
@@ -3455,6 +3456,29 @@ DeleteMenuCloneEntries(menuPtr, first, last)
/*
*----------------------------------------------------------------------
*
+ * TkMenuCleanup --
+ *
+ * Resets menusInitialized to allow Tk to be finalized and reused
+ * without the DLL being unloaded.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TkMenuCleanup(ClientData unused)
+{
+ menusInitialized = 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMenuInit --
*
* Sets up the hash tables and the variables used by the menu package.
@@ -3474,13 +3498,17 @@ TkMenuInit()
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
+
if (!menusInitialized) {
Tcl_MutexLock(&menuMutex);
if (!menusInitialized) {
TkpMenuInit();
menusInitialized = 1;
}
+ /*
+ * Make sure we cleanup on finalize.
+ */
+ Tcl_CreateExitHandler((Tcl_ExitProc *) TkMenuCleanup, NULL);
Tcl_MutexUnlock(&menuMutex);
}
if (!tsdPtr->menusInitialized) {