diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index b8a04b47ac..e94b5bb79e 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -69,7 +69,7 @@ CameraWidget::CameraWidget(std::string stream_name, VisionStreamType type, QWidg setAttribute(Qt::WA_OpaquePaintEvent); qRegisterMetaType>("availableStreams"); QObject::connect(this, &CameraWidget::vipcThreadConnected, this, &CameraWidget::vipcConnected, Qt::BlockingQueuedConnection); - QObject::connect(this, &CameraWidget::vipcThreadFrameReceived, this, &CameraWidget::vipcFrameReceived, Qt::QueuedConnection); + // QObject::connect(this, &CameraWidget::vipcThreadFrameReceived, this, &CameraWidget::vipcFrameReceived, Qt::QueuedConnection); QObject::connect(this, &CameraWidget::vipcAvailableStreamsUpdated, this, &CameraWidget::availableStreamsUpdated, Qt::QueuedConnection); QObject::connect(QApplication::instance(), &QCoreApplication::aboutToQuit, this, &CameraWidget::stopVipcThread); } diff --git a/tools/clip/application.cc b/tools/clip/application.cc index 9048486742..52cbec0571 100644 --- a/tools/clip/application.cc +++ b/tools/clip/application.cc @@ -71,22 +71,25 @@ Application::Application(int argc, char *argv[], QObject *parent) : QObject(pare recorderThread = new QThread; recorder = new Recorder(outputFile.toStdString()); recorder->moveToThread(recorderThread); - QObject::connect(recorderThread, &QThread::finished, recorder, &QObject::deleteLater); + connect(recorderThread, &QThread::finished, recorder, &QObject::deleteLater); + connect(app, &QCoreApplication::aboutToQuit, recorderThread, &QThread::quit); - QObject::connect(window, &OnroadWindow::redrew, this, [&]() { + QTimer *loop = new QTimer; + connect(loop, &QTimer::timeout, this, [&]() { + if (!window->isVisible()) { + return; + } QElapsedTimer timer; timer.start(); QPixmap pixmap = window->grab(); - // qDebug() << "pixmap took " << timer.elapsed() << " ms"; + qDebug() << "pixmap took " << timer.elapsed() << " ms"; timer.restart(); recorder->saveFrame(std::make_shared(std::move(pixmap))); - // qDebug() << "save frame took" << timer.elapsed() << " ms"; - }, Qt::QueuedConnection); - - QObject::connect(app, &QCoreApplication::aboutToQuit, recorderThread, &QThread::quit); + }); + loop->start(1000 / UI_FREQ); - // window->setAttribute(Qt::WA_DontShowOnScreen); - window->setAttribute(Qt::WA_Mapped); + window->setAttribute(Qt::WA_DontShowOnScreen); + window->setAttribute(Qt::WA_OpaquePaintEvent); window->setAttribute(Qt::WA_NoSystemBackground); recorderThread->start();