From dd9c7de89a8bf876d3d7f7e98c55ac428539a4c8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 22 May 2018 14:39:11 +0200 Subject: [PATCH] Tracing: Fix past-end handling in TraceStashFile::Iterator If we read past the end of the stream in open() or next() we don't want to process the resulting event. This fixes the QmlProfilerTraceClient test. Change-Id: Iaaa60f462aa588096001579efae7ed1a88d6d6a3 Reviewed-by: Tobias Hunger --- src/libs/tracing/tracestashfile.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libs/tracing/tracestashfile.h b/src/libs/tracing/tracestashfile.h index f8096e08fe0..c3443e13001 100644 --- a/src/libs/tracing/tracestashfile.h +++ b/src/libs/tracing/tracestashfile.h @@ -75,10 +75,13 @@ public: { if (readFile->open(QIODevice::ReadOnly)) { readStream->setDevice(readFile.get()); - if (readStream->atEnd()) + if (readStream->atEnd()) { streamAtEnd = true; - else + } else { (*readStream) >> nextEvent; + if (readPastEnd()) + streamAtEnd = true; + } return true; } streamAtEnd = true; @@ -107,6 +110,8 @@ public: const Event result = std::move(nextEvent); (*readStream) >> nextEvent; + if (readPastEnd()) + streamAtEnd = true; return result; }