UI: fix cameraview crash after going offroad in settings window (#23009) (#23068)

Co-authored-by: Dean Lee <deanlee3@gmail.com>
pull/23090/head v0.8.11
Adeeb Shihadeh 2021-11-29 15:49:41 -08:00 committed by GitHub
parent bf338bf5e9
commit 1e0ef417c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

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