From c73d9ddaa61af2e04146e9be5c51f80dc7450f09 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 18 Oct 2021 17:03:30 +0800 Subject: [PATCH] replay: fix hanging on shutdown while downloading (#22592) --- selfdrive/ui/replay/route.cc | 9 +++++---- selfdrive/ui/replay/route.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/replay/route.cc b/selfdrive/ui/replay/route.cc index a7aa4a28e6..6d2eff18ae 100644 --- a/selfdrive/ui/replay/route.cc +++ b/selfdrive/ui/replay/route.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include "selfdrive/hardware/hw.h" #include "selfdrive/ui/qt/api.h" @@ -108,15 +107,17 @@ Segment::Segment(int n, const SegmentFile &files, bool load_dcam, bool load_ecam for (int i = 0; i < std::size(file_list); i++) { if (!file_list[i].isEmpty()) { loading_++; - synchronizer_.addFuture(QtConcurrent::run(this, &Segment::loadFile, i, file_list[i].toStdString())); + loading_threads_.emplace_back(QThread::create(&Segment::loadFile, this, i, file_list[i].toStdString()))->start(); } } } Segment::~Segment() { aborting_ = true; - synchronizer_.setCancelOnWait(true); - synchronizer_.waitForFinished(); + for (QThread *t : loading_threads_) { + if (t->isRunning()) t->wait(); + delete t; + } } void Segment::loadFile(int id, const std::string file) { diff --git a/selfdrive/ui/replay/route.h b/selfdrive/ui/replay/route.h index c4ab0cd2a3..80d275f6d3 100644 --- a/selfdrive/ui/replay/route.h +++ b/selfdrive/ui/replay/route.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include "selfdrive/common/util.h" #include "selfdrive/ui/replay/framereader.h" @@ -57,5 +57,5 @@ protected: std::atomic success_ = true, aborting_ = false; std::atomic loading_ = 0; - QFutureSynchronizer synchronizer_; + std::list loading_threads_; };