summaryrefslogtreecommitdiffstats
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
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]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkMenu.c32
2 files changed, 35 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2cf8a9c..8b6887c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-02-25 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tkMenu.c (TkMenuCleanup): make sure to reset static
+ menusInitialized on finalize. [Bug #548729]
+
2003-02-25 Daniel Steffen <das@users.sourceforge.net>
* macosx/tkMacOSXHLEvents.c: fixed conversion of apple event
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) {