From 67c6ed939514e537773f9f01cc2ecca5c3400c44 Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Mon, 13 Apr 2026 15:29:51 -0400 Subject: [PATCH] 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. --- tcltk/toolkit.tcl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tcltk/toolkit.tcl b/tcltk/toolkit.tcl index 006577a5..5d3f06ad 100644 --- a/tcltk/toolkit.tcl +++ b/tcltk/toolkit.tcl @@ -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 }