Skip to content

Commit 59d0fba

Browse files
committed
fix UI hang when switching streams
1 parent 85a162d commit 59d0fba

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

tools/cabana/mainwin.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,19 @@ void MainWindow::loadFromClipboard(SourceSet s, bool close_all) {
311311
}
312312

313313
void MainWindow::openStream(AbstractStream *stream, const QString &dbc_file) {
314+
if (can) {
315+
QObject::connect(can, &QObject::destroyed, this, [=]() { startStream(stream, dbc_file); });
316+
can->deleteLater();
317+
} else {
318+
startStream(stream, dbc_file);
319+
}
320+
}
321+
322+
void MainWindow::startStream(AbstractStream *stream, QString dbc_file) {
314323
center_widget->clear();
315324
delete messages_widget;
316325
delete video_splitter;
317326

318-
delete can;
319327
can = stream;
320328
can->setParent(this); // take ownership
321329
can->start();

tools/cabana/mainwin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public slots:
4444
void updateProgressBar(uint64_t cur, uint64_t total, bool success);
4545

4646
protected:
47+
void startStream(AbstractStream *stream, QString dbc_file);
4748
bool eventFilter(QObject *obj, QEvent *event) override;
4849
void remindSaveChanges();
4950
void closeFile(SourceSet s = SOURCE_ALL);

tools/replay/replay.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ void Replay::setupSegmentManager(bool has_filters) {
5959
}
6060

6161
Replay::~Replay() {
62-
seg_mgr_.reset();
6362
if (stream_thread_.joinable()) {
6463
rInfo("shutdown: in progress...");
6564
interruptStream([this]() {
@@ -70,6 +69,7 @@ Replay::~Replay() {
7069
rInfo("shutdown: done");
7170
}
7271
camera_server_.reset();
72+
seg_mgr_.reset();
7373
}
7474

7575
bool Replay::load() {

0 commit comments

Comments
 (0)