summaryrefslogtreecommitdiffstats
path: root/generic/tkImage.c
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2003-01-22 14:32:59 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2003-01-22 14:32:59 (GMT)
commit63621bfadbb2827543dec4243c786dc8e6eb81ff (patch)
treed36caa6a34005845deeb4fa8eb884defa7bafe80 /generic/tkImage.c
parent4341d6e81b11c58379c44c1709c06525a0e4e9c4 (diff)
downloadtk-63621bfadbb2827543dec4243c786dc8e6eb81ff.zip
tk-63621bfadbb2827543dec4243c786dc8e6eb81ff.tar.gz
tk-63621bfadbb2827543dec4243c786dc8e6eb81ff.tar.bz2
* generic/tkImage.c (Tk_ImageObjCmd): Added check to make sure
that you're not creating an image named the same as .'s command, which refixes 220891, even when the name of the command has been changed with 'rename'. The error message is better too. * generic/tkFrame.c (TkToplevelWindowForCommand): Added way of mapping from command names to tkwins-for-toplevels. * tests/image.test (image-1.10,image-1.11): Updated to match new error message and added test for the rename case. * generic/tclInt.decls: Made TkToplevelWindowForCommand exported privately.
Diffstat (limited to 'generic/tkImage.c')
-rw-r--r--generic/tkImage.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/generic/tkImage.c b/generic/tkImage.c
index 3312aef..feb65ab 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.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: tkImage.c,v 1.18 2003/01/19 09:50:01 hobbs Exp $
+ * RCS: @(#) $Id: tkImage.c,v 1.19 2003/01/22 14:32:59 dkf Exp $
*/
#include "tkInt.h"
@@ -237,8 +237,23 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
name = idString;
firstOption = 3;
} else {
+ TkWindow *topWin;
+
name = arg;
firstOption = 4;
+ /*
+ * Need to check if the _command_ that we are about to
+ * create is the name of the current master widget
+ * command (normally "." but could have been renamed)
+ * and fail in that case before a really nasty and
+ * hard to stop crash happens.
+ */
+ topWin = (TkWindow *) TkToplevelWindowForCommand(interp, name);
+ if (topWin != NULL && winPtr->mainPtr->winPtr == topWin) {
+ Tcl_AppendResult(interp, "images may not be named the ",
+ "same as the main window", (char *) NULL);
+ return TCL_ERROR;
+ }
}
/*