Version: 1.7.0 (using KDE 3.5.8KDE 1.2) Installed from: 0Compiled From Sources OS: Linux Problem: Executing a KstScript file to construct a new DataVector and check its propety skip and skipLength, and the js file returns an unexpected result. Procedures to reproduce the proplem: create a js file: datavec.js var s=new DataSource("/home/vyiwen/graphics/kst/tests/asciimatrix.txt"); function skipTest() { var result = new Boolean(); var v=new DataVector(s,"test1",0,10,0,false)//construct a new vector from data //source, and read 10 frames from //frame 0 and skip 0 frame if(v.skip==false&&v.skipLength==0) result=true else result=false return result;//expect result=true } Load datavec.js Open the kst javaScript Console Type "skipTest()" return false To compare with the result from executing the above script directly from JavaScript Console Type the following codes in JavaScript Console: kst> var s=new DataSource("/home/vyiwen/graphics/kst/tests/asciimatrix.txt"); kst> var v=new DataVector(s,"test1",0,10,0,false) kst> if(v.skip==false&&v.skipLength==0){result=true} true kst> result true The result is true
Created attachment 24548 [details] the source file to create the data vector
Created attachment 24549 [details] the js file used to excute the kstscript in the problem description
This is a "feature" Because updates on most objects in Kst occur asynchronously you can never be sure when an object has actually been updated. The code "works" when entered by hand as there is a sufficiently long gap between creation of the Data Vector and querying for its values, that the necessary updates have been completed. The code "fails" when run via the script as sufficient time is not available. This can be seen by putting in an alert() statement immediately after creating the Data Vector and before querying for vector values. The expected values will now be returned.
This is actually a problem as it places a severe onus on a client of the javaScript extension of Kst to ensure that an update has occured before querying for the results.
SVN commit 806977 by arwalker: CCBUG:161397 first draft of allowing the client to make 'synchronous' calls to the Kst javaScript extension. M +5 -0 kst.cpp M +1 -0 kst.h M +70 -7 updatethread.cpp M +6 -2 updatethread.h WebSVN link: http://websvn.kde.org/?view=rev&revision=806977
SVN commit 806978 by arwalker: CCBUG:161397 first draft of allowing the client to make 'synchronous' calls to the Kst javaScript extension. M +17 -3 bind_kst.cpp M +5 -0 bind_kst.h WebSVN link: http://websvn.kde.org/?view=rev&revision=806978
If a client wants to make a "synchronous" call they should make the call as usual and then make a call to Kst.waitForUpdate(). The latter call will return only after the next update loop has completed, thereby ensuring that the actions of the original call have been fully propagated.