From: SourceForge.net <no...@so...> - 2009-08-26 14:33:36
|
Bugs item #2844964, was opened at 2009-08-26 10:33 Message generated for change (Tracker Item Submitted) made by kchansen You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2844964&group_id=12997 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 03. [*button] and [label] Group: current: 8.6b1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Karl C. Hansen (kchansen) Assigned to: Jeffrey Hobbs (hobbs) Summary: (also tcl 2844962) Tcl_UpdateLinkedVar doesn't trigger widge Initial Comment: Also tested in 8.5.7, same behavior. Also tried ENTRY widgets OS Platform & Version WinXP with SP3 Problem Behavior Updates to linked C variables do not trigger widget updates. If I update a Tcl variable that is tied to a widget, the widget is automatically updated, presumably via hooks similar to the trace mechanism. Unfortunately, this does not seem to occur if the variables are tied to C variables. Calling Tcl_UpdateLinkedVar() *does* update the Tcl-side, since the following proc demonstrates the updates are occurring by displaying the Tcl-side values every two seconds when called via "Update 2000": proc Update {interval} { if {$::Thresh} { puts "***************************************************************" puts "Red: $::RMax" puts "Green: $::GMax" puts "Blue: $::BMax" puts "Interval $interval" update } after $interval "Update $interval" } Even though the Tcl variables reflect the updates, the widget values DO NOT refresh until I manipulate the widget window (e.g. resize). Below are the pertinent code snippets. I originally tried defining R/G/BMax as longs, and using them directly, but it occurred to me that perhaps the update needed to have string variables since the widgets use "-textvariable" options. Changing the code to the below code had the same behavior. I also tried calling Tcl_InvalidateStringRep() in the same C routine which calls Tcl_UpdateLinkedVar() with no changes to behavior. ***tcl*** label .v2.lrmax.rMax -textvariable ::RMax label .v2.lgmax.gMax -textvariable ::GMax label .v2.lbmax.bMax -textvariable ::BMax ***init*** sRMax = Tcl_Alloc(256); sGMax = Tcl_Alloc(256); sBMax = Tcl_Alloc(256); Tcl_LinkVar(theInterp, "::RMax", (char *) &sRMax, TCL_LINK_STRING | TCL_LINK_READ_ONLY); Tcl_LinkVar(theInterp, "::GMax", (char *) &sGMax, TCL_LINK_STRING | TCL_LINK_READ_ONLY); Tcl_LinkVar(theInterp, "::BMax", (char *) &sBMax, TCL_LINK_STRING | TCL_LINK_READ_ONLY); ***update*** sprintf(sRMax, "%lu", RMax); Tcl_UpdateLinkedVar(mainInterp, "::RMax"); sprintf(sGMax, "%lu", GMax); Tcl_UpdateLinkedVar(mainInterp, "::GMax"); sprintf(sBMax, "%lu", BMax); Tcl_UpdateLinkedVar(mainInterp, "::BMax"); ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2844964&group_id=12997 |