cabana: fix PandaStream crash if no panda found (#27948)

old-commit-hash: dc4b7b37c0
This commit is contained in:
Dean Lee
2023-04-19 01:22:57 +08:00
committed by GitHub
parent ca245b4973
commit 679ae7865a
4 changed files with 9 additions and 1 deletions
+1
View File
@@ -1,6 +1,7 @@
#include "tools/cabana/streams/devicestream.h"
DeviceStream::DeviceStream(QObject *parent, QString address) : zmq_address(address), LiveStream(parent) {
startStreamThread();
}
void DeviceStream::streamThread() {
+6 -1
View File
@@ -8,10 +8,15 @@ LiveStream::LiveStream(QObject *parent) : AbstractStream(parent, true) {
util::create_directories(path, 0755);
fs.reset(new std::ofstream(path + "/rlog" , std::ios::binary | std::ios::out));
}
stream_thread = new QThread(this);
QObject::connect(stream_thread, &QThread::started, [=]() { streamThread(); });
QObject::connect(stream_thread, &QThread::finished, stream_thread, &QThread::deleteLater);
}
void LiveStream::startStreamThread() {
// delay the start of the thread to avoid calling startStreamThread
// in the constructor when other classes' slots have not been connected to
// the signals of the livestream.
QTimer::singleShot(0, [this]() { stream_thread->start(); });
}
+1
View File
@@ -14,6 +14,7 @@ public:
double getSpeed() override { return speed_; }
bool isPaused() const override { return pause_; }
void pause(bool pause) override;
void startStreamThread();
protected:
virtual void handleEvent(Event *evt);
+1
View File
@@ -13,6 +13,7 @@ PandaStream::PandaStream(QObject *parent, PandaStreamConfig config_) : config(co
if (!connect()) {
throw std::runtime_error("Failed to connect to panda");
}
startStreamThread();
}
bool PandaStream::connect() {