mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
replay: fix concurrency issues (#29797)
fix concurrency issues old-commit-hash: bbf133a2e505bee6dc502a3b636a59ae6b254798
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user