summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-12-13 23:13:51 (GMT)
committerhobbs <hobbs>2007-12-13 23:13:51 (GMT)
commit9fd974286cb1cb9402e5f080122f3ec6d7cf5ff0 (patch)
tree453f8a4c1e37ddb4dc0b46975cbe4518959269c6
parentf6b3b8871d886c215eb8d780664c34e2ba21b172 (diff)
downloadtk-9fd974286cb1cb9402e5f080122f3ec6d7cf5ff0.zip
tk-9fd974286cb1cb9402e5f080122f3ec6d7cf5ff0.tar.gz
tk-9fd974286cb1cb9402e5f080122f3ec6d7cf5ff0.tar.bz2
* generic/tkMenubutton.c (ConfigureMenuButton): trace the
-textvariable even if an image exists as it may use -compound.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkMenubutton.c50
2 files changed, 28 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index f9990e3..7c68cb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-13 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tkMenubutton.c (ConfigureMenuButton): trace the
+ -textvariable even if an image exists as it may use -compound.
+
2007-12-12 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tkText.c (DeleteChars, TextEditCmd, updateDirtyFlag):
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index 000b4f9..6ee966e 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.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: tkMenubutton.c,v 1.12.2.1 2003/11/17 23:29:36 hobbs Exp $
+ * RCS: @(#) $Id: tkMenubutton.c,v 1.12.2.2 2007/12/13 23:13:52 hobbs Exp $
*/
#include "tkMenubutton.h"
@@ -620,32 +620,28 @@ ConfigureMenuButton(interp, mbPtr, objc, objv)
Tk_FreeSavedOptions(&savedOptions);
}
- if ((mbPtr->image == NULL) && (mbPtr->bitmap == None)
- && (mbPtr->textVarName != NULL)) {
-
- /*
- * The menubutton displays the value of a variable.
- * Set up a trace to watch for any changes in it, create
- * the variable if it doesn't exist, and fetch its
- * current value.
- */
-
- CONST char *value;
-
- value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
- TCL_GLOBAL_ONLY);
- } else {
- if (mbPtr->text != NULL) {
- ckfree(mbPtr->text);
- }
- mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(mbPtr->text, value);
- }
- Tcl_TraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
+ if (mbPtr->textVarName != NULL) {
+ /*
+ * If no image or -compound is used, display the value of a variable.
+ * Set up a trace to watch for any changes in it, create the variable
+ * if it doesn't exist, and fetch its current value.
+ */
+ CONST char *value;
+
+ value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
+ if (value == NULL) {
+ Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
+ TCL_GLOBAL_ONLY);
+ } else {
+ if (mbPtr->text != NULL) {
+ ckfree(mbPtr->text);
+ }
+ mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
+ strcpy(mbPtr->text, value);
+ }
+ Tcl_TraceVar(interp, mbPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuButtonTextVarProc, (ClientData) mbPtr);
}
TkMenuButtonWorldChanged((ClientData) mbPtr);