Corrected the handling of toolkit callbacks created by the

"magic::add_dependency" procedure.  The "check" function should always
be called first, followed by the dependencies.  Because otherwise, if
an incorrect value is entered for a device parameter, then it gets
used to calculate dependent values *before* it gets corrected by the
"check" procedure, resulting in an incorrect value being displayed
for the dependent value, even after the bad entry has been corrected.
This commit is contained in:
R. Timothy Edwards 2026-04-13 15:29:51 -04:00
parent f15f0dabbb
commit 67c6ed9395
1 changed files with 8 additions and 3 deletions

View File

@ -1299,6 +1299,11 @@ proc magic::add_check_callbacks {gencell_type library} {
# A final default dependency will be added to all entries
# to run the "check" procedure for the device. Dependencies
# that are more targeted get run first.
#
# NOTE: The "check" procedure must be the first in the
# list, as otherwise, any invalid entry that is corrected
# by the check callback will have been used to evaluate
# dependent values.
#----------------------------------------------------------
proc magic::add_dependency {callback gencell_type library args} {
@ -1355,13 +1360,13 @@ proc magic::update_dialog {callback pname gencell_type library} {
set parameters [dict merge $pdefaults [magic::gencell_getparams]]
}
if {$callback != {}} {
set parameters [$callback $pname $parameters]
}
if {[catch {set parameters [${library}::${gencell_type}_check $parameters]} \
checkerr]} {
puts stderr $checkerr
}
if {$callback != {}} {
set parameters [$callback $pname $parameters]
}
magic::gencell_setparams $parameters
}