Bug 234403 - Equation is corrupted upon changing data file
Summary: Equation is corrupted upon changing data file
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.7.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-15 02:41 UTC by Andrew Walker
Modified: 2010-04-19 20:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2010-04-15 02:41:17 UTC
Version:           1.7.0 (using KDE 4.4.2)
OS:                Linux
Installed from:    Compiled From Sources

The following was submitted to kst.kde.org by email:

=================

I defined some equations which calculate the resistance of an NTC temperature sensor from the raw data reading which is a voltage. The equation looks like this:

([Channel0]/[Channel5]*[Rref])/(1-[Channel0]/[Channel5]) 

where Channel0 is the voltage reading, Channel5 the reference voltage (also logged) and Rref a scalar.

Now when I change the data file all equations get corrupted. The above looks like this after changing to the new data file:

(/[Channel5]*[Rref])/(1-/[Channel5]) 
so Channel0 is simply missing.

Interestingly the data show up right in all plots so when reading the data file everything seems to be calculated right.

The problem is when I save the kst file all equations are lost as they are not valid expressions and are not saved to the kst file. When I reload the kst file after saving with corrupted equations the equations are simply empty.
Comment 1 Andrew Walker 2010-04-16 02:39:34 UTC
The problem is caused by KstObjectCollection::doRename()

This function is responsible for tearing down the tag, changing the name, and then building up the newly named tag.

However, the call to change the tag's name (KstObject::setTagName()), emits the signal tagChanged. This causes any equation using the tag to be reparsed, but the tag being renamed has not yet been rebuilt, so it is not found.

The equation will still work, but the rebuilt text of the equation will be invalid as a result. Thus saving the session and reloading will result in an invalid equation.

The solution is to emit the tagChanged signal at the correct time.

An even better solution would be to hold off on reparsing any equations until all the tags had been renamed, being considerably more efficient.
Comment 2 Andrew Walker 2010-04-19 20:24:18 UTC
SVN commit 1116538 by arwalker:

BUG:234403 Fix problem with timing of notification of name changes of vector to equations

 M  +2 -0      libkst/kstmatrix.cpp  
 M  +10 -0     libkst/kstobject.cpp  
 M  +1 -0      libkst/kstobject.h  
 M  +1 -1      libkst/kstobjectcollection.h  
 M  +2 -0      libkst/kstscalar.cpp  
 M  +2 -0      libkst/kststring.cpp  
 M  +2 -0      libkst/kstvector.cpp  
 M  +0 -2      libkstmath/kstequation.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1116538