This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Variable errors


Hi,

The recent changes to variables.tcl to deal with changing types in 
variables is not quite correct:

-821,8 +824,22 @@ class VariableWin {
        set ChangeList {}
        set variables [$Hlist info children {}]
        foreach var $variables {
-           #      debug "VARIABLE: $var ($Update($this,$var))"
-           set ChangeList [concat $ChangeList [$var update]]
+           # debug "VARIABLE: $var ($Update($this,$var))"
+           set UpdatedList [$var update]
+            if {[lindex $UpdatedList 0] == $var} {
+              debug "Type changed."
+              # We must fix the tree entry to correspond to the new type
+              $Hlist delete offsprings $var
+              $Hlist entryconfigure $var -text [label $var]
+              if {[$var numChildren] > 0} {
+                $Tree setmode $var open
+              } else {
+                $Tree setmode $var none
+              }
+            } else {
+             set ChangeList [concat $ChangeList $UpdatedList]
+             # debug "ChangeList=$ChangeList"
+            }
        }

There are two problems here. We'll start with the easy one.

When the type of a variable changes, this code (correctly) deletes the 
offsprings of the variable and configures the existing entry to 
correspond to the latest version of the variable. However, it does not 
add itself to the ChangeList, so it never appears to be updated (its 
value changes in the window, but the value is never highlighted in blue). 
The (obvious?) fix is to add "set UpdatedList $var" in the "type changed" 
block.

Now the tougher one. This statement is incorrect:
+            if {[lindex $UpdatedList 0] == $var} {
+              debug "Type changed."

This means that ANY root variable whose value changes is going to have 
its offspring deleted and the variable (if it has any displayed children) 
will also be collapsed. So if I change the value of a struct* which I was 
viewing, all the children go away.

The other side affect is that simple variables like integers also never 
show up in the ChangeList. Adding the "set UpdateList $var" fix above 
will work around this, though, as kludgy as it is.

Is there a better way to find out if the type has changed?? Can we add a 
new gdbtk-varobj variable method to check this, i.e., let the variable 
explicitly tell us that its type has changed? Then we could do something 
like:

     if {[$var typeChanged]} {
       debug "Type changed"

This would be a much more definitive test.
Keith



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]