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

old-commit-hash: dc4b7b37c0
beeps
Dean Lee 2 years ago committed by GitHub
parent ca245b4973
commit 679ae7865a
  1. 1
      tools/cabana/streams/devicestream.cc
  2. 7
      tools/cabana/streams/livestream.cc
  3. 1
      tools/cabana/streams/livestream.h
  4. 1
      tools/cabana/streams/pandastream.cc

@ -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() {

@ -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(); });
}

@ -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);

@ -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() {

Loading…
Cancel
Save