Tk Library Source Code

View Ticket
Login
Ticket UUID: 532783
Title: Linked matrix not propagating changes
Type: Bug Version: None
Submitter: kenj Created on: 2002-03-20 22:47:02
Subsystem: struct :: matrix Assigned To: andreas_kupries
Priority: 6 Severity:
Status: Closed Last Modified: 2002-03-26 01:55:11
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2002-03-25 18:55:11
Description:
The documentation for the ::struct::matrix operation implies 
that after linking, changes to the matrix object will be propagated 
to the linked array variable. However, it isn't happening. Here's a 
simple test case run interactively:

% package require 
struct
1.2
% ::struct::matrix test
test
% test add columns 
4
% test add row {1 2 3}
% test link arr
% array get arr
0,0 1 1,0 2 
2,0 3 3,0 {}
% test add row {a b c d}
% array get arr
0,0 1 1,0 2 2,0 3 
3,0 {}

Line 1245 of the source looks suspiciously like it has a 
typo of the variable name "data":

trace variable date  w  [list 
::struct::matrix::MatTraceOut $variable $name]

However, 
changing "date" to "data" in this line didn't work:

% package 
require struct
1.2
% ::struct::matrix test
test
% test add 
columns 4
% test add row {1 2 3}
% test link arr
% array get 
arr
0,0 1 1,0 2 2,0 3 3,0 {}
% test add row {a b c d}
can't set 
"data(0,1)": can't set "array(0,1)": bad row index 1, row does not 
exist
User Comments: andreas_kupries added on 2002-03-26 01:55:11:
Logged In: YES 
user_id=75003

Patch comitted to head.

andreas_kupries added on 2002-03-22 01:05:59:
Logged In: YES 
user_id=75003

Ken, can you give this patch a whirl ?

andreas_kupries added on 2002-03-21 12:35:12:

File Added - 19763: 532783.diff

Logged In: YES 
user_id=75003

Here is a patch.

andreas_kupries added on 2002-03-21 12:21:47:
Logged In: YES 
user_id=75003

And yes, the "date" vs. "data" thing is a bug,
one which was already fixed in the CVS head.

andreas_kupries added on 2002-03-21 12:20:12:
Logged In: YES 
user_id=75003

I have determined how the error is generated.

In the method "add row" data is set into cells,
actually into the internal array of the matrix.
This triggers the trace and via MatTraceOut the
external array is set too. This then triggers
the trace we have on that array and MatTraceIn
is called. This command uses "set cell" to set
the value into the matrix. But at the time we
are calling the method we are in the middle of
"add row" and the internal structures, especially
the information on how many rows the matrix
contains, are not uptodate. Because of this the
*range check* performed by "set cell" fails and
generates the error message we see, namely that
the argument to "set cell" are out of bounds.

My solution would be to disable MatTraceIn when we
are inside of MatTraceOut. This will take care of
all situations where this can occur and not only of
this specific case.

andreas_kupries added on 2002-03-21 12:02:32:
Logged In: YES 
user_id=75003

Verified, is in CVS head too.

Attachments: