cabana: stop stream thread before exiting main event loop (#32634)

stop stream thread before exiting main event loop
pull/32635/head
Dean Lee 11 months ago committed by GitHub
parent bbc21b9f52
commit 1d61f320a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      tools/cabana/cabana.cc
  2. 2
      tools/cabana/streams/abstractstream.cc
  3. 4
      tools/cabana/streams/replaystream.cc
  4. 1
      tools/cabana/streams/replaystream.h
  5. 1
      tools/replay/replay.cc

@ -91,7 +91,6 @@ int main(int argc, char *argv[]) {
w.openStream(); w.openStream();
} }
w.show(); w.show();
int ret = app.exec();
delete can; return app.exec();
return ret;
} }

@ -3,6 +3,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include <QApplication>
#include "common/timing.h" #include "common/timing.h"
#include "tools/cabana/settings.h" #include "tools/cabana/settings.h"
@ -19,6 +20,7 @@ AbstractStream::AbstractStream(QObject *parent) : QObject(parent) {
assert(parent != nullptr); assert(parent != nullptr);
event_buffer_ = std::make_unique<MonotonicBuffer>(EVENT_NEXT_BUFFER_SIZE); event_buffer_ = std::make_unique<MonotonicBuffer>(EVENT_NEXT_BUFFER_SIZE);
QObject::connect(QApplication::instance(), &QCoreApplication::aboutToQuit, this, &AbstractStream::stop);
QObject::connect(this, &AbstractStream::privateUpdateLastMsgsSignal, this, &AbstractStream::updateLastMessages, Qt::QueuedConnection); QObject::connect(this, &AbstractStream::privateUpdateLastMsgsSignal, this, &AbstractStream::updateLastMessages, Qt::QueuedConnection);
QObject::connect(this, &AbstractStream::seekedTo, this, &AbstractStream::updateLastMsgsTo); QObject::connect(this, &AbstractStream::seekedTo, this, &AbstractStream::updateLastMsgsTo);
QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &AbstractStream::updateMasks); QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &AbstractStream::updateMasks);

@ -64,6 +64,10 @@ void ReplayStream::start() {
replay->start(); replay->start();
} }
void ReplayStream::stop() {
replay.reset(nullptr);
}
bool ReplayStream::eventFilter(const Event *event) { bool ReplayStream::eventFilter(const Event *event) {
static double prev_update_ts = 0; static double prev_update_ts = 0;
if (event->which == cereal::Event::Which::CAN) { if (event->which == cereal::Event::Which::CAN) {

@ -16,6 +16,7 @@ class ReplayStream : public AbstractStream {
public: public:
ReplayStream(QObject *parent); ReplayStream(QObject *parent);
void start() override; void start() override;
void stop() override;
bool loadRoute(const QString &route, const QString &data_dir, uint32_t replay_flags = REPLAY_FLAG_NONE); bool loadRoute(const QString &route, const QString &data_dir, uint32_t replay_flags = REPLAY_FLAG_NONE);
bool eventFilter(const Event *event); bool eventFilter(const Event *event);
void seekTo(double ts) override; void seekTo(double ts) override;

@ -56,6 +56,7 @@ Replay::~Replay() {
stream_thread_->quit(); stream_thread_->quit();
stream_thread_->wait(); stream_thread_->wait();
delete stream_thread_; delete stream_thread_;
stream_thread_ = nullptr;
} }
timeline_future.waitForFinished(); timeline_future.waitForFinished();
rInfo("shutdown: done"); rInfo("shutdown: done");

Loading…
Cancel
Save