[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Feb 2 00:17:24 CET 2005


CVS commit by staikos: 

Adjust skip based on comments and patches over the past couple of weeks.
Accelerated skip is probably broken.


  M +14 -4     kstrvector.cpp   1.75


--- kdeextragear-2/kst/kst/kstrvector.cpp  #1.74:1.75
@@ -432,4 +432,8 @@ KstObject::UpdateType KstRVector::doUpda
   checkIntegrity();
 
+  if (DoSkip && Skip < 2) {
+    DoSkip = false;
+  }
+
   if (!_file) {
     return NO_CHANGE;
@@ -460,7 +464,10 @@ KstObject::UpdateType KstRVector::doUpda
   if (DoSkip) {
     // change new_f0 and new_nf so they both lie on skip boundaries
-    tmp_fn = ((new_f0+new_nf)/Skip) * Skip;
-    new_f0 = (((new_f0-1)/Skip)+1) * Skip;
-    new_nf = tmp_fn-new_f0;
+    //tmp_fn = ((new_f0 + new_nf)/Skip) * Skip - 1;
+    tmp_fn = new_f0 + new_nf - 1;
+    // new_f0 == 0 results in (new_f0 - 1)/Skip being -0.x which rounds the
+    // wrong way on us.  Therefore new_f0 == 0 is a special case.
+    new_f0 = new_f0 == 0 ? 0 : (((new_f0 - 1)/Skip) + 1) * Skip - 1;
+    new_nf = tmp_fn - new_f0 + 1;
   }
 
@@ -490,4 +497,5 @@ KstObject::UpdateType KstRVector::doUpda
   if (DoSkip) {
     // reallocate V if necessary
+    //kdDebug() << "new_nf = " << new_nf << " and skip = " << Skip << " so new_nf/Skip+1 = " << (new_nf / Skip + 1) << endl;
     if (new_nf / Skip != _size) {
       bool rc = resize(new_nf/Skip);
@@ -519,5 +527,6 @@ KstObject::UpdateType KstRVector::doUpda
       n_read = 0;
       /** read each sample from the File */
-      for (i = NF, j = 0; i < new_nf; i += Skip, j++) {
+      //kdDebug() << "NF = " << NF << " numsamples = " << _numSamples << " new_f0 = " << new_f0 << endl;
+      for (i = NF, j = 0; i < new_nf && (new_nf - i) >= Skip; i += Skip, j++) {
         if (DoAve) {
           /* enlarge AveReadBuf if necessary */
@@ -538,4 +547,5 @@ KstObject::UpdateType KstRVector::doUpda
           }
         } else {
+          //kdDebug() << "readField " << _field << " start=" << new_f0 + i << " n=-1" << endl;
           n_read += _file->readField(_v + _numSamples + j, _field, new_f0 + i, -1);
         }




More information about the Kst mailing list