Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 75425bb0d4d8cbcb745e57237d01929bc3701267a9c1a5c23aea06f6aa3a1086
Ticket: a58737f57bf740979e0ed091118508188b8c28f5
The macOS implementation of Tcl_WaitForEvent is incorrect.
User & Date: kevin_walzer on 2020-07-13 12:24:12
Changes

  1. icomment:
    Can't figure out how to attach a file - any suggestions? Anyway, here is the demo code.
    
    <verbatim>
    
    variable main_loop_stack {}
    variable stack_height 0
    proc push_main_task {args} {
       variable main_loop_stack
       lappend main_loop_stack $args
    }
    proc completion_main_loop {} {
       variable main_loop_stack
       variable stack_height [llength $main_loop_stack]
       if {[llength $main_loop_stack]} then {
          set cmd [lindex $main_loop_stack end]
          set main_loop_stack [lreplace $main_loop_stack end end]
       } else {
          set cmd increment_count
       }
       eval $cmd
       after 0 [list after idle completion_main_loop]
    }
    variable main_count 0
    proc increment_count {} {
       variable main_count
       incr main_count
       push_main_task count_down $main_count
    }
    proc count_down {n} {
       after 5
       if {$n} then {push_main_task count_down [expr {$n-1}]}
    }
    interp alias {} pause_main_loop {} push_main_task return
    proc halt_main_loop {} {
       variable main_loop_stack
       set main_loop_stack [linsert $main_loop_stack 0 return]
    }
    eval {
       toplevel .control
       grid [
          label .control.lcount -textvariable main_count
       ] x [
          label .control.lheight -textvariable stack_height
       ]
       grid [
          button .control.halt -text "Halt" -command halt_main_loop
       ] [
          button .control.pause -text "Pause" -command pause_main_loop
       ] [
          button .control.run -text "Run" -command completion_main_loop
       ]
       wm title .control "Control panel"
    }
    
    
    
    </verbatim>
    
  2. login: "kevin_walzer"
  3. mimetype: "text/html"