Tk Library Source Code

View Ticket
Login
Ticket UUID: 1165534
Title: Listbox bug, a non-stop loop cause the shaking of the widge
Type: Bug Version: None
Submitter: pharmatcl Created on: 2005-03-17 20:18:38
Subsystem: bwidget Assigned To: damonc
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-06-30 21:22:59
Resolution: Out of Date Closed By: oehhar
    Closed on: 2009-06-30 14:22:59
Description:
Following is a test code, please run it and your will
see a ScrolledWindow shaking. 

Before you run it, please make sure that "CP: 555  *
AAA-I am shaking wildly 10mm dia:  59.5 mm" is in a
single line. The length of the list item name really
matters.

######### test code starts ######################
set bwidget_path *YOUR BWIDGET PATH HERE*
lappend auto_path $bwidget_path
package require BWidget
                                                      
                         
toplevel  .shaking
                                                      
                         
set f [frame .shaking.butF]
                                                      
                         
set sw [ScrolledWindow $f.sw -auto both\
            -relief sunken -borderwidth 2]
                                                      
                         
set marksList [ListBox $f.lb -relief flat -borderwidth 0 \
                -padx 0 -height 8 -width 40 -bg white]
                                                      
                         
$sw setwidget $marksList
                                                      
                         
grid $sw -row 0 -column 0 -columnspan 6 -pady 0 -padx 2m
                                                      
                         
$marksList insert end 1 -text "1"
$marksList insert end 2 -text "2"
$marksList insert end 3 -text "3"
$marksList insert end 4 -text "CP: 555  * AAA-I am
shaking wildly 10mm dia:  59.5 mm"
# make sure that "CP: 555  * AAA-I am shaking wildly
10mm dia:  59.5 mm" is a single line
$marksList insert end 5 -text "5"
$marksList insert end 6 -text "6"
$marksList insert end 7 -text "7"
$marksList insert end 8 -text "8"
                                                      
                         
pack $f       
#### test code ends #################################

#### test environment ################################
If you run it by wish8.3, no problme at all, 
if you run it by wish8.4, you got  a shaking widget.

My testing environment:
      1. Redhat Linux  2.4.21-9.ELsmp
      2. BWidget-1.7.0, tcl 8.4, and tk 8.4
      3. Default font

#### Code analysis ##################################
Bwidget induces an endless loop through a "bind" command.
(In Bwidget-1.7.0),
In line 105 of listbox.tcl:
  bind ListBox <Configure> [list ListBox::_resize  %W]

In proc ListBox::_resize, line 1139 of listbox.tcl:
it call _update_scrollregion :

    } else {
        if {[Widget::cget $path -selectfill]} {
            _update_select_fill $path
        }
        _update_scrollregion $path # this line triggers
an endless loop
    }

In proc ListBox::_update_scrollregion, line 918 of
listbox.tcl
  it call $path.c configure -scrollregion [list 0 0 $w $h] 
  This triggers ListBox <Configure> event and call
_resize again, forming a loop.

If you put in "puts " commands in _resize and
_update_scrollregion
you will see _resize and _update_scrollregion called
alternatively
 
Removing line 1139, "_update_scrollregion $path",
dismantles the shaking.
User Comments: oehhar added on 2009-06-30 21:22:59:
It does not happen for me on current cvs on linux or windows for tk8.5.7.

This might also be due to an improved locking in the widget.

I close the bug, complain if it is still an issue.

dev_null42a added on 2006-03-25 01:25:27:
Logged In: YES 
user_id=1381097

After some analysis, it appears that too many configure and
resize events are being generated, causing Tk's event ring
buffer to overflow.[1]  As an experiment, I ran the provided
test program under differing window managers; the shaking
behavior occurs when differing number of items are added to
the ListBox.  I see no clean way of resolving this problem.

[1] This error was first reported as Bug 795608, "tk binding
problem in Gnome and Ximian".  My analysis to comp.lang.tcl
may be found at http://tinyurl.com/l6dfd.

pharmatcl added on 2005-03-18 03:18:39:

File Added - 126128: shakingScrolledWindow.tcl

Attachments: