Skip to content
Tcl Source Code History Of Ticket 2844962
Login

History Of Ticket 2844962

Artifacts Associated With Ticket 2844962

  1. Ticket change [747ca7dbec] (rid 105211) by kchansen on 2009-08-26 14:21:51:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.6b1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "kchansen"
    10. subsystem initialized to: "09. Linked C Variables"
    11. title initialized to:
      Tcl_UpdateLinkedVar does not trigger tk widget updates
      
    12. type initialized to: "Bug"
  2. Ticket change [836c935110] (rid 117379) by dgp on 2009-08-28 04:54:02:

    1. icomment:
      
      Are you calling Tcl_UpdateLinkedVar() within
      the handler of a trace on the linked Tcl variable?
      
      If not, I'm not seeing easily how you could have
      the failure you report.  The guts of 
      Tcl_UpdateLinkedVar() is simply a call
      to Tcl_ObjSetVar2() which should trigger
      write traces in this context just the same
      as it does in any other context.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  3. Ticket change [2b6bfd00fb] (rid 118738) by dgp on 2009-08-28 04:55:39:

    1. icomment:
      
      Ah, perhaps the widgets are being updated just
      fine, but their displayed appearance does not
      reflect the new values yet because the event
      loop has not yet processed idle handlers?  Any
      chance that is the real problem here?
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [b492cc0403] (rid 125065) by dgp on 2009-08-28 04:58:15:

    1. icomment:
      It might be helpful if the original reporter
      would attach some working demos to
      this report.  Then there could be less
      guessing and more analysis.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [2359ceb769] (rid 130911) by kchansen on 2009-08-30 05:57:49:

    1. icomment:
      I have created a stripped-down demo that does not depend on any external DLLs (other than my own DLL & Tcl/Tk dlls).  I'll create a zip file with the source files for the Tcl interface and the tcl script demonstrating the problem.
      
      
    2. login: "kchansen"
    3. mimetype: "text/plain"
    4. username: "kchansen"
  6. Ticket change [3652c02e24] (rid 107090) by kchansen on 2009-08-30 05:59:01:

    1. icomment:
      
      
      File Added - 341062: CleanExample.zip
      
      
      
    2. login: "kchansen"
    3. mimetype: "text/plain"
    4. username: "kchansen"
  7. Add attachment "CleanExample.zip" [d7d64b3759] (rid 107334) by kchansen on 2009-08-30 05:59:01.

  8. Ticket change [351b57f865] (rid 106867) by kchansen on 2009-08-30 06:06:29:

    1. icomment:
      Thanks for looking at this!
      
      Unzip the file "CleanExample.zip" to an empty directory.  It contains four files:
      
      VidKt.dll -- A video toolkit with Tcl/Tk hooks (display video in any frame!  :) )
         (This dll is copyright 2009, Karl C. Hansen, All rights reserved.)  It is provided to assist with debugging this issue.
      
      Callback.cpp -- The video callback hook that serves up frames to the Tcl code.  Also renders frames into the display window.
      
      TclUtils.cpp -- The Tcl-side of the interface, simply counts the frames.  Also handles initialization of the global variables.
      
      vt.tcl -- builds the video control panel, designates the display window, creates a window to show the counter, starts the video stream.  Shows the Tcl console.
      
      Clicking on "Show Updates" in the little counter window starts displaying the current value of Counter every two seconds.  Counter is changing when displayed via Tcl code, but not in the little widget.
      
      If you resize the window displaying Counter, the value will update.
      
      If you drag *any* window in front of the counter window then away, the value updates.  It really looks like the widget just is not redrawing even though the text variable has changed....
      
      
      
      
    2. login: "kchansen"
    3. mimetype: "text/plain"
    4. username: "kchansen"
  9. Ticket change [6d28431bd5] (rid 128639) by dgp on 2009-09-01 23:29:59:

    1. assignee changed to: "dgp"
    2. priority changed to: "9 Immediate"
  10. Ticket change [69d1298746] (rid 128044) by dgp on 2009-09-02 00:47:12:

    1. icomment:
      
      oops.  sorry, after looking, I can't
      work with that demo kit.
      
      I don't do Windows.
      
      I'll open the sources in case they adapt
      easily.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [a3753dd869] (rid 110049) by dgp on 2009-09-02 00:47:16:

    1. priority changed to: "5 Medium"
  12. Ticket change [f7a015311c] (rid 91406) by dgp on 2009-09-02 00:51:28:

    1. icomment:
      
      No, it's a much bigger and more complex demo
      than I have time to dissect now.
      
      The essense of your bug report seems simple.
      Why such a big demo?
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [d06a05d68a] (rid 113179) by kchansen on 2009-09-02 06:03:48:

    1. icomment:
      The demo is large because of all the hoops that Micro$soft created through which code must jump in order to hook live video streams.  All I *really* want to do is collect raw buffers from a streaming source at the other end of a firewire or USB 2.0+ connection.
      
      The video hook is in a different thread, but calls back into the Tcl thread asynchronously to the routine in Callback.cpp.  Once my thread gets notified I am just counting the frames.
      
      Perhaps a simple dual-thread system might work to demonstrate it.
      
      I'll see if I can create a dual-thread demo where one thread waits for random intervals on a timer and then notifies the Tcl code via a callback.
      
      Thanks for looking at it!
      
      I'm working on porting the library to Linux and Mac, but my real job gets in the way....  :)
      
      
    2. login: "kchansen"
    3. mimetype: "text/plain"
    4. username: "kchansen"
  14. Ticket change [61078acb26] (rid 92173) by ferrieux on 2009-09-02 14:19:13:

    1. icomment:
      Well, a callback from an alien thread is *not* the way Tcl is supposed to be notified. The Async.3 manpage has the details.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  15. Ticket change [210e4037db] (rid 130518) by kchansen on 2009-09-02 23:19:17:

    1. icomment:
      EUREKA!
      
      <Pauses while epiphany sinks in>
      
      I was *wondering* how one would protect other code from a misbehaving callback.  I think we definitely need to add links from the *Link* descriptions to the *Async* descriptions, with a note that says something to the effect:
      
      "Critical Note: Modifying a linked variable asynchronously from C (e.g. in response to a signal or interrupt) requires additional measures to protect the system.  See Tcl_AsyncCreate() and Tcl_AsyncMark() for details."
      
      I have tagged this as *CLOSED-INVALID*, but definitely want to push for the addition to the documentation.  I have left the status as "OPEN" for comment posting.
      
      I added a call to Tcl_AsyncCreate() to my init function, and my callback now does the calcs against the C variables, then calls Tcl_AsyncMark().  The async handler calls the Tcl_UpdateLinkedVar() for each of the touched variables.  Now the values are updating beautifully!
      
      Thanks again for the quick work on this!
      
      I would have left this open and just changed the category but "other" is too vague, and I don't see a category for "documentation/helpfile"....
      
      
    2. login: "kchansen"
    3. mimetype: "text/plain"
    4. username: "kchansen"
  16. Ticket change [efb254e2c1] (rid 109045) by kchansen on 2009-09-02 23:19:19:

    1. closedate changed to: "2009-09-02T16:19:19"
    2. closer changed to: "kchansen"
    3. resolution changed to: "Invalid"
    4. status changed to: "Closed"
  17. Ticket change [7e673dbc39] (rid 97404) by dkf on 2009-09-03 15:08:17:

    1. icomment:
      Added some text to HEAD documentation. It mentions Tcl_ThreadQueueEvent and Tcl_AsyncMark, which indicate the two key methods for handling this sort of thing (they're totally different strategies BTW).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  18. Ticket change [dd524a00b7] (rid 114645) by dkf on 2009-09-03 15:08:21:

    1. icomment:
      
      
      allow_comments - 1
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"