Skip to content

Commit

Permalink
UI: fix cameraview crash after going offroad in settings window (comm…
Browse files Browse the repository at this point in the history
…aai#23009) (commaai#23068)

Co-authored-by: Dean Lee <[email protected]>
  • Loading branch information
adeebshihadeh and deanlee committed Nov 29, 2021
1 parent bf338bf commit 1e0ef41
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions selfdrive/ui/qt/widgets/cameraview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,21 @@ void CameraViewWidget::initializeGL() {

void CameraViewWidget::showEvent(QShowEvent *event) {
latest_frame = nullptr;
vipc_thread = new QThread();
connect(vipc_thread, &QThread::started, [=]() { vipcThread(); });
connect(vipc_thread, &QThread::finished, vipc_thread, &QObject::deleteLater);
vipc_thread->start();
if (!vipc_thread) {
vipc_thread = new QThread();
connect(vipc_thread, &QThread::started, [=]() { vipcThread(); });
connect(vipc_thread, &QThread::finished, vipc_thread, &QObject::deleteLater);
vipc_thread->start();
}
}

void CameraViewWidget::hideEvent(QHideEvent *event) {
vipc_thread->requestInterruption();
vipc_thread->quit();
vipc_thread->wait();
if (vipc_thread) {
vipc_thread->requestInterruption();
vipc_thread->quit();
vipc_thread->wait();
vipc_thread = nullptr;
}
}

void CameraViewWidget::updateFrameMat(int w, int h) {
Expand Down

0 comments on commit 1e0ef41

Please sign in to comment.