summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkFrame.c44
-rw-r--r--generic/tkImage.c17
-rw-r--r--generic/tkInt.decls7
-rw-r--r--generic/tkIntDecls.h10
-rw-r--r--generic/tkStubInit.c3
5 files changed, 76 insertions, 5 deletions
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index 63e8245..f4f0a53 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.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: tkFrame.c,v 1.14 2003/01/03 22:43:45 hobbs Exp $
+ * RCS: @(#) $Id: tkFrame.c,v 1.15 2003/01/22 14:32:59 dkf Exp $
*/
#include "default.h"
@@ -1933,3 +1933,45 @@ FrameLostSlaveProc(clientData, tkwin)
}
FrameWorldChanged((ClientData) framePtr);
}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * TkToplevelWindowFromCommandToken --
+ *
+ * If the given command name to the command for a toplevel window
+ * in the given interpreter, return the tkwin for that toplevel
+ * window. Note that this lookup can't be done using the
+ * standard tkwin internal table because the command might have
+ * been renamed.
+ *
+ * Results:
+ * A Tk_Window token, or NULL if the name does not refer to a
+ * toplevel window.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+Tk_Window
+TkToplevelWindowForCommand(interp, cmdName)
+ Tcl_Interp *interp;
+ CONST char *cmdName;
+{
+ Tcl_CmdInfo cmdInfo;
+ Frame *framePtr;
+
+ if (Tcl_GetCommandInfo(interp, cmdName, &cmdInfo) == 0) {
+ return NULL;
+ }
+ if (cmdInfo.objProc != FrameWidgetObjCmd) {
+ return NULL;
+ }
+ framePtr = (Frame *) cmdInfo.objClientData;
+ if (framePtr->type != TYPE_TOPLEVEL) {
+ return NULL;
+ }
+ return framePtr->tkwin;
+}
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;
+ }
}
/*
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 1b105ae..951bb45 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -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: tkInt.decls,v 1.32 2002/12/08 00:46:51 hobbs Exp $
+# RCS: @(#) $Id: tkInt.decls,v 1.33 2003/01/22 14:32:59 dkf Exp $
library tk
@@ -668,6 +668,11 @@ declare 147 generic {
void TkStylePkgFree (TkMainInfo *mainPtr)
}
+declare 148 generic {
+ Tk_Window TkToplevelWindowForCommand(Tcl_Interp *interp,
+ CONST char *cmdName)
+}
+
##############################################################################
# Define the platform specific internal Tcl interface. These functions are
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index 88ca960..d50dab4 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -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: tkIntDecls.h,v 1.21 2002/08/31 06:12:20 das Exp $
+ * RCS: @(#) $Id: tkIntDecls.h,v 1.22 2003/01/22 14:33:00 dkf Exp $
*/
#ifndef _TKINTDECLS
@@ -556,6 +556,9 @@ EXTERN void TkSubtractRegion _ANSI_ARGS_((TkRegion sra,
EXTERN void TkStylePkgInit _ANSI_ARGS_((TkMainInfo * mainPtr));
/* 147 */
EXTERN void TkStylePkgFree _ANSI_ARGS_((TkMainInfo * mainPtr));
+/* 148 */
+EXTERN Tk_Window TkToplevelWindowForCommand _ANSI_ARGS_((
+ Tcl_Interp * interp, CONST char * cmdName));
typedef struct TkIntStubs {
int magic;
@@ -830,6 +833,7 @@ typedef struct TkIntStubs {
#endif /* MAC_OSX_TK */
void (*tkStylePkgInit) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 146 */
void (*tkStylePkgFree) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 147 */
+ Tk_Window (*tkToplevelWindowForCommand) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * cmdName)); /* 148 */
} TkIntStubs;
#ifdef __cplusplus
@@ -1535,6 +1539,10 @@ extern TkIntStubs *tkIntStubsPtr;
#define TkStylePkgFree \
(tkIntStubsPtr->tkStylePkgFree) /* 147 */
#endif
+#ifndef TkToplevelWindowForCommand
+#define TkToplevelWindowForCommand \
+ (tkIntStubsPtr->tkToplevelWindowForCommand) /* 148 */
+#endif
#endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index e2bc17a..259baf3 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkStubInit.c,v 1.40 2002/12/08 00:46:51 hobbs Exp $
+ * RCS: @(#) $Id: tkStubInit.c,v 1.41 2003/01/22 14:33:00 dkf Exp $
*/
#include "tkInt.h"
@@ -328,6 +328,7 @@ TkIntStubs tkIntStubs = {
#endif /* MAC_OSX_TK */
TkStylePkgInit, /* 146 */
TkStylePkgFree, /* 147 */
+ TkToplevelWindowForCommand, /* 148 */
};
TkIntPlatStubs tkIntPlatStubs = {