• Error while selecting from combobox

    From alexandru.dadalau@alexandru.dadalau@meshparts.de (alexandru) to comp.lang.tcl on Tue Feb 11 07:40:49 2025
    From Newsgroup: comp.lang.tcl

    This is random error, could not be reproduced yet.

    It happend while the user selected a value from a ttk::combobox.

    There is a trace to the combobox variable, added with: trace add
    variable $varname write $callback

    But the error does not seem to have anything with the callback function.

    It's a rather internal issue.

    Any ideas?

    Thanks
    Alex


    *** END OF ERROR MESSAGE ***} -errorlog 1}
    1: {::bgerrorhandler
    {Index 2 out of range}
    {-code 1
    -level 0
    -errorstack
    {INNER {invokeStk1 vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3 current
    2}
    CALL {SelectEntry vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3 2}
    CALL {LBSelect vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l}
    CALL {ttk::combobox::LBSelected vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l}
    }
    -errorcode
    {TTK COMBOBOX IDX_RANGE}
    -errorinfo
    {Index 2 out of range
    while executing
    "$cb current $index"
    (procedure "SelectEntry" line 2)
    invoked from within
    "SelectEntry $cb [lindex $selection 0]"
    (procedure "LBSelect" line 5)
    invoked from within
    "LBSelect $lb"
    (procedure "ttk::combobox::LBSelected" line 3)
    invoked from within
    "ttk::combobox::LBSelected vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l
    "
    (command bound to event)} -errorline 1}}
    0: {::meshparts::showstack file2a8350dd0}

    --
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From nemethi@csaba.nemethi@t-online.de to comp.lang.tcl on Tue Feb 11 17:57:39 2025
    From Newsgroup: comp.lang.tcl

    Am 11.02.25 um 08:40 schrieb alexandru:
    This is random error, could not be reproduced yet.

    It happend while the user selected a value from a ttk::combobox.

    There is a trace to the combobox variable, added with: trace add
    variable $varname write $callback

    But the error does not seem to have anything with the callback function.

    It's a rather internal issue.

    Any ideas?

    Thanks
    Alex


    *** END OF ERROR MESSAGE ***} -errorlog 1}
    1: {::bgerrorhandler
    {Index 2 out of range}
    {-code 1
    -level 0
    -errorstack
       {INNER {invokeStk1 vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3 current
    2}
       CALL {SelectEntry vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3 2}
       CALL {LBSelect vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l}
       CALL {ttk::combobox::LBSelected vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l}
    }
    -errorcode
       {TTK COMBOBOX IDX_RANGE}
    -errorinfo
       {Index 2 out of range
       while executing
    "$cb current $index"
       (procedure "SelectEntry" line 2)
       invoked from within
    "SelectEntry $cb [lindex $selection 0]"
       (procedure "LBSelect" line 5)
       invoked from within
    "LBSelect $lb"
       (procedure "ttk::combobox::LBSelected" line 3)
       invoked from within
    "ttk::combobox::LBSelected vpan.main.workframe.detailsframe.sw.sf.mf.cf.asmpar.solve.cb3.popdown.f.l
    "
       (command bound to event)} -errorline 1}}
    0: {::meshparts::showstack file2a8350dd0}

    --

    The reported issue is easy to reproduce:

    set cb [ttk::combobox .cb -state readonly -values {a b c}]
    $cb current 0
    pack $cb -padx 20 -pady 20
    after 5000 { $cb configure -values {a b}; puts "value list changed" }

    Pop down the listbox associated with the combobox *immediately*, wait
    until you see the message "value list changed", and then click on the
    last list element. As a result, an error dialog will pop up, displaying
    the following message:

    index "2" out of range
    index "2" out of range
    while executing
    "$cb current $index"
    (procedure "SelectEntry" line 2)
    invoked from within
    "SelectEntry $cb [lindex $selection 0]"
    (procedure "LBSelect" line 5)
    invoked from within
    "LBSelect $lb"
    (procedure "ttk::combobox::LBSelected" line 3)
    invoked from within
    "ttk::combobox::LBSelected .cb.popdown.f.l "
    (command bound to event)

    I suspect that your application does something similar, namely it
    manipulates the value list while the user is selecting a value. To
    prevent such situations, the application should not be allowed to change
    the values if the listbox is popped down, i.e., if the following holds true:

    [winfo exists $cb.popdown] && [winfo ismapped $cb.popdown]
    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From alexandru.dadalau@alexandru.dadalau@meshparts.de (alexandru) to comp.lang.tcl on Tue Feb 11 18:32:42 2025
    From Newsgroup: comp.lang.tcl

    Many thanks Csaba.
    This could be tha case, though the user would have to be pretty fast in clicking, because the values are set while the widget is shown.
    I'll take a closer look.

    Regards
    Alex

    --
    --- Synchronet 3.20c-Linux NewsLink 1.2