Tk Source Code

Artifact [81bc3291]
Login

Artifact 81bc32917d3d05b11e2fd82f9a8a4da4f6117341:

Attachment "oldconfig.patch" to ticket [749908ff] added by hobbs 2005-12-06 05:45:19.
Index: generic/tkOldConfig.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkOldConfig.c,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 tkOldConfig.c
--- generic/tkOldConfig.c	14 Sep 2005 23:27:02 -0000	1.12.2.2
+++ generic/tkOldConfig.c	5 Dec 2005 22:20:16 -0000
@@ -75,11 +75,11 @@
  */
 
 int
-Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags)
+Tk_ConfigureWidget(interp, tkwin, origSpecs, argc, argv, widgRec, flags)
     Tcl_Interp *interp;		/* Interpreter for error reporting. */
     Tk_Window tkwin;		/* Window containing widget (needed to
 				 * set up X resources). */
-    Tk_ConfigSpec *specs;	/* Describes legal options. */
+    Tk_ConfigSpec *origSpecs;	/* Describes legal options. */
     int argc;			/* Number of elements in argv. */
     CONST char **argv;		/* Command-line options. */
     char *widgRec;		/* Record whose fields are to be
@@ -90,7 +90,7 @@
 				 * for them to be considered.  Also,
 				 * may have TK_CONFIG_ARGV_ONLY set. */
 {
-    register Tk_ConfigSpec *specPtr;
+    register Tk_ConfigSpec *specs, *specPtr, *origSpecPtr;
     Tk_Uid value;		/* Value of option from database. */
     int needFlags;		/* Specs must contain this set of flags
 				 * or else they are not considered. */
@@ -114,10 +114,15 @@
     }
 
     /*
-     * Get the build of the config for this interpreter.
+     * Get the build of the config for this interpreter and reset any
+     * indication of changed options.
      */
 
-    specs = GetCachedSpecs(interp, specs);
+    specs = GetCachedSpecs(interp, origSpecs);
+
+    for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
+	specPtr->specFlags &= ~TK_CONFIG_OPTION_SPECIFIED;
+    }
 
     /*
      * Pass one:  scan through all of the arguments, processing those
@@ -159,9 +164,18 @@
 	    Tcl_AddErrorInfo(interp, msg);
 	    return TCL_ERROR;
 	}
-	if (!(flags & TK_CONFIG_ARGV_ONLY)) {
-	    specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED;
-	}
+	specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED;
+    }
+
+    /*
+     * Thread Unsafe!  For compatibility through 8.4.x, we set the original
+     * specPtr flags to indicate changed options.  This has been removed
+     * from 8.5.  Switch to Tcl_Obj-based options instead. [Bug 749908]
+     */
+
+    for (origSpecPtr = origSpecs, specPtr = specs;
+	 specPtr->type != TK_CONFIG_END; origSpecPtr++, specPtr++) {
+	origSpecPtr->specFlags = specPtr->specFlags;
     }
 
     /*
@@ -176,7 +190,6 @@
 	    if ((specPtr->specFlags & TK_CONFIG_OPTION_SPECIFIED)
 		    || (specPtr->argvName == NULL)
 		    || (specPtr->type == TK_CONFIG_SYNONYM)) {
-		specPtr->specFlags &= ~TK_CONFIG_OPTION_SPECIFIED;
 		continue;
 	    }
 	    if (((specPtr->specFlags & needFlags) != needFlags)
@@ -191,7 +204,7 @@
 		if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) !=
 			TCL_OK) {
 		    char msg[200];
-    
+
 		    sprintf(msg, "\n    (%s \"%.50s\" in widget \"%.50s\")",
 			    "database entry for",
 			    specPtr->dbName, Tk_PathName(tkwin));
@@ -209,7 +222,7 @@
 		    if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) !=
 			    TCL_OK) {
 			char msg[200];
-	
+
 			sprintf(msg,
 				"\n    (%s \"%.50s\" in widget \"%.50s\")",
 				"default value for",
@@ -1136,7 +1149,6 @@
 		    specPtr->defValue = Tk_GetUid(specPtr->defValue);
 		}
 	    }
-	    specPtr->specFlags &= ~TK_CONFIG_OPTION_SPECIFIED;
 	}
     } else {
 	cachedSpecs = (Tk_ConfigSpec *) Tcl_GetHashValue(entryPtr);