Tk Source Code

View Ticket
Login
Ticket UUID: 3137232
Title: spinbox error after destroying toplevel from widget
Type: Bug Version: obsolete: 8.5.9
Submitter: hirner Created on: 2010-12-14 12:36:40
Subsystem: 17. [spinbox] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-03-07 07:26:22
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-03-07 07:26:22
Description:
#!/bin/sh
#\
exec vmwish "$0" ${1+"$@"}

################################################################################
# Fehlerbeschreibung:
#   1. <Button-1> auf dem "Pfeil oben"-Knopf gedrückt halten bis Spinbox automatisch hochgezählt wird. 
#   2. Dann mit gedrückter Maustaste den Knopf verlassen. (Endlosschleife in ::tk::spinbox::Invoke)
#   3. dann die Maustaste ausserhalb los lassen und dann den Knopf "Zerstöre Toplevel" drücken.
#   4 . nach Abschluss der for-Schleife => Applikationsfehler da Spinbox in der Schleife ::Invoke 
#       nicht mehr existiert.
################################################################################

################################################################################
# Bug in spinbox.tcl
#1. Hold mouse button over the "buttonup arrow" till the spinner automatically increment the value. 
#2. Then move the mouse cursor while hold Button-1 pressed away from the "buttonup arrow" and now button release.
#3. Then TK enter a loop ::tk::spinbox::Invoke in /usr/lib/tcl/tk8.5/spinbox.tcl
#4. Now press the button "Destroy Toplevel" while -command "todo" proc is computing.
#5  After finishing the -command todo proc a Application Error occurs.
#
#6. Sorry for my english...
#invalid command name ".t.sp"
#invalid command name ".t.sp"
#    while executing
#"$w cget -repeatinterval"
#    (procedure "::tk::spinbox::Invoke" line 8)
#    invoked from within
#"::tk::spinbox::Invoke .t.sp buttonup"
#    ("after" script)
#


################################################################################
# use this example-code to test the error.

wm withdraw .
toplevel .t
set sp [spinbox .t.sp \
             -validate key \
             -command todo \
             -width 2 \
             -from 1 \
             -to 99 \
             -increment 1]
pack $sp
pack [button .t.b -text "Destroy Toplevel" -command beenden]

################################################################################ 
proc todo {} {
   for {set i 0 } {$i < 2500} {incr i} {
      puts "$i Datum: >>[exec date]<<"
   }
   return
}
################################################################################
proc beenden {} {
   destroy .t
   return
}
User Comments: fvogel added on 2016-03-07 07:26:22:
Merged in trunk and core-8-6-branch.

fvogel added on 2016-02-25 15:18:11:
Thaks for the review.

To ease dgp's work in realizing the current 8.6 release, I think we should refrain from merging new fixes until 8.6.5 is out. Unless dgp wants this in 8.6.5, but then he makes that decision/merge.

jan.nijtmans added on 2016-02-25 14:08:52:
Fix looks fine to me, and is harmless. +1 for merging to trunk

fvogel added on 2016-02-22 21:50:40:
OK, problem reproduced on Linux Debian 6.0.

Now I understand.

On Windows I could not reproduce because I had removed [exec date] in proc todo since that statement triggered an error on Win7. Without that statement, proc todo is much much quicker to execute and this makes a lot of difference.

On Linux I reproduce with the script provided by the OP.

The first thing to emphasize is that execution of proc todo is quite long but there is no endless loop at all. Then, when pushing the Destroy button during execution of proc todo then we obtain the reported error because the widget gets destroyed before the events piled up before had a chance to be consumed (again, because proc todo takes time to execute).

On Windows one can reproduce easily when replacing proc todo with the following:
  proc todo {} {
     for {set i 0 } {$i < 100000} {incr i} {
        puts "$i"
     }
     return
  }

Then click and maintain the up arrow of the spinbox depressed for a while, move the mouse away and, during the time the numbers are written in the console, hit the Destroy button. The error is then triggered.

I have proposed a fix in branch bug-3137232fff.

fvogel added on 2016-02-22 16:19:49:
On Windows 7 I cannot see the issue you are describing. There is no endless loop for me, and therefore no error when pushing the Destroy button.

I will try on Linux as well, but I think this endless loop problem got fixed one way or another since this report was issued.

Is anyone able to reproduce perhaps?

hirner added on 2010-12-15 12:31:49:

File Added - 396150: testTclUlli.tcl

hirner added on 2010-12-15 12:31:22:

File Deleted - 396069:

hirner added on 2010-12-14 19:36:41:

File Added - 396069: testTclUlli.tcl

Attachments: