Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 747ca7dbec33d9e19f80bab875d0de91264401c7
Ticket: 2844962fffffffffffffffffffffffffffffffff
Tcl_UpdateLinkedVar does not trigger tk widget updates
User & Date: kchansen on 2009-08-26 14:21:51
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Also tested in 8.5.7, same behavior.
    
    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");
    
    
    
  4. foundin changed to: "obsolete: 8.6b1"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "kchansen"
  10. subsystem changed to: "09. Linked C Variables"
  11. title changed to:
    Tcl_UpdateLinkedVar does not trigger tk widget updates
    
  12. type changed to: "Bug"