Fix NPE with traces that are time scaled.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfIterator.java
index d215d76371f84bf47187d779a949d8797be0d00b..62add563df8ee91460fab568d9751e418dddc8dc 100644 (file)
@@ -122,7 +122,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
 
         /* Adjust the timestamp depending on the trace's offset */
         long currTimestamp = ctfLocationData.getTimestamp();
-        final long offsetTimestamp = currTimestamp - this.getTrace().getOffset();
+        final long offsetTimestamp = this.getCtfTmfTrace().getCTFTrace().timestampNanoToCycles(currTimestamp);
         if (offsetTimestamp < 0) {
             ret = super.seek(0L);
         } else {
@@ -133,17 +133,21 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
          * Check if there is already one or more events for that timestamp, and
          * assign the location index correctly
          */
-        currTimestamp = this.getCurrentEvent().getTimestampValue();
         long index = 0;
-        for (long i = 0; i < ctfLocationData.getIndex(); i++) {
-            if (currTimestamp == this.getCurrentEvent().getTimestampValue()) {
-                index++;
-            } else {
-                index = 0;
+        if (this.getCurrentEvent() != null) {
+            currTimestamp = this.getCurrentEvent().getTimestampValue();
+
+            for (long i = 0; i < ctfLocationData.getIndex(); i++) {
+                if (currTimestamp == this.getCurrentEvent().getTimestampValue()) {
+                    index++;
+                } else {
+                    index = 0;
+                }
+                this.advance();
             }
-            this.advance();
+        } else {
+            ret= false;
         }
-
         /* Seek the current location accordingly */
         if (ret) {
             curLocation.setLocation(new CtfLocationData(getCurrentEvent().getTimestampValue(), index));
This page took 0.025157 seconds and 5 git commands to generate.