replay: fix concurrency issues (#29797)

fix concurrency issues
old-commit-hash: bbf133a2e5
test-msgs
Dean Lee 2 years ago committed by GitHub
parent 64c3dc5ad6
commit 87c8ec0e5c
  1. 12
      tools/replay/replay.cc

@ -151,9 +151,10 @@ void Replay::buildTimeline() {
[(int)cereal::ControlsState::AlertStatus::CRITICAL] = TimelineType::AlertCritical,
};
for (auto it = segments_.cbegin(); it != segments_.cend() && !exit_; ++it) {
const auto &route_segments = route_->segments();
for (auto it = route_segments.cbegin(); it != route_segments.cend() && !exit_; ++it) {
LogReader log;
if (!log.load(route_->at(it->first).qlog.toStdString(), &exit_,
if (!log.load(it->second.qlog.toStdString(), &exit_,
{cereal::Event::Which::CONTROLS_STATE, cereal::Event::Which::USER_FLAG},
!hasFlag(REPLAY_FLAG_NO_FILE_CACHE), 0, 3)) continue;
@ -227,7 +228,10 @@ void Replay::segmentLoadFinished(bool success) {
if (!success) {
Segment *seg = qobject_cast<Segment *>(sender());
rWarning("failed to load segment %d, removing it from current replay list", seg->seg_num);
segments_.erase(seg->seg_num);
updateEvents([&]() {
segments_.erase(seg->seg_num);
return true;
});
}
queueSegment();
}
@ -456,7 +460,7 @@ void Replay::stream() {
}
if (eit == events_->end() && !hasFlag(REPLAY_FLAG_NO_LOOP)) {
int last_segment = segments_.rbegin()->first;
int last_segment = segments_.empty() ? 0 : segments_.rbegin()->first;
if (current_segment_ >= last_segment && isSegmentMerged(last_segment)) {
rInfo("reaches the end of route, restart from beginning");
QMetaObject::invokeMethod(this, std::bind(&Replay::seekTo, this, 0, false), Qt::QueuedConnection);

Loading…
Cancel
Save