Sujet : Re: Error while selecting from combobox
De : csaba.nemethi (at) *nospam* t-online.de (nemethi)
Groupes : comp.lang.tclDate : 11. Feb 2025, 17:57:39
Autres entêtes
Message-ID : <vofvi3$3hqq$1@tota-refugium.de>
References : 1
User-Agent : Mozilla Thunderbird
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 0pack $cb -padx 20 -pady 20after 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