Tk Library Source Code

View Ticket
Login
Ticket UUID: 1752755
Title: An error dialog pops up while ListBox is resizing
Type: Bug Version: None
Submitter: legolas_a20 Created on: 2007-07-12 16:36:50
Subsystem: bwidget Assigned To: damonc
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-06-10 15:49:08
Resolution: Accepted Closed By: oehhar
    Closed on: 2009-06-10 08:49:08
Description:
(See also discussion at http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/97c4892c68312e6b/1b31a8239ee3d4cd?lnk=raot#1b31a8239ee3d4cd , although the initial ideas at what went wrong were wrong).

Run the attached file, click the button and you'll get this error dialog:
----------------------------
unknown widget .sw.lb.a1
unknown widget .sw.lb.a1
    while executing
"Widget::cget $path $option"
    (procedure "Widget::getoption" line 6)
    invoked from within
"Widget::getoption $path.$item $option"
    (procedure "_getoption" line 2)
    invoked from within
"_getoption $path $item -foreground"
    (procedure "_redraw_selection" line 11)
    invoked from within
"_redraw_selection $path"
    (procedure "_update_select_fill" line 13)
    invoked from within
"_update_select_fill $path"
    (procedure "ListBox::_resize" line 27)
    invoked from within
"ListBox::_resize .sw.lb"
    (command bound to event)
----------------------------

Note that the whole callstack is inside BWidget's ListBox class.

I'm running "ActiveState ActiveTcl 8.4.14.0.272572   Nov 26, 2006", according to the readme and the software. This contains BWidget 1.8. I'm on Windows XP SP2.) 

Something appears to be going wrong while resizing, but only if the -selectfill true option is set, I think only if the ListBox is inside a ScrollWindow. At the time of the resize, I can see the scrollbars pop up and immediatly disappear again(indeed they are not needed at all in this case).

As a bonus bug(?): it is not possible to add items whose name contains :: or ends in : . From the errors, it seems like this is because the name passed in is directly used as a variable name.

As noted in the newsgroup, the bug can be worked around by not causing the resize at that point in the code, although I have no idea why. The solution in the newsgroup (after 1 [list .b configure -text "[.b cget -text]aaaa"] ) doesn't always work, after 5 ... does seem to work, and for my own code, I have inserted an 'update idletasks' in between changing the listbox contents and the change to the other widgets (those changes then cause the resize).
User Comments: oehhar added on 2009-06-10 15:49:08:
Commited to cvs

oehhar added on 2009-06-09 22:28:29:
Bug confirmed.
Listbox deltes the item widget as bwidget (bwidget::delete) but postphones the delete in the canvas to a after idletasks routine.
An eventual pending resize event may be executed between the two tasks.
The error may arise due to the half deleted item widget.

A patch is attached. It consists of a check if the widget (to update) is on the "to-delete" list.
Alternate solutions:
- a simple catch -> drawback -> errorInfo pollution
- a check if the widget was removed (widget::exists path.item

Patch for listbox.tcl:
1069,1070c1069,1072
<         $path.c itemconfigure "n:$item" \
<             -fill [_getoption $path $item -foreground]
---
>         if {-1 == [lsearch -exact $data(upd,delete) $item]} {
>             $path.c itemconfigure "n:$item" \
>                 -fill [_getoption $path $item -foreground]
>         }

legolas_a20 added on 2007-07-12 23:36:50:

File Added - 236747: bwidgetListBoxBug.tk

Attachments: