From 2d4329767e5e5b75e29ff009909eaa3b21488fc9 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Fri, 24 Oct 2014 13:42:08 +0200 Subject: [PATCH] Delay webcam res probing until first use Fixes #520 --- src/camera.cpp | 13 +++++++------ src/camera.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/camera.cpp b/src/camera.cpp index 7e5cc2046..3beb6b712 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -26,6 +26,7 @@ Camera::Camera() : refcount(0) , workerThread(nullptr) , worker(nullptr) + , needsInit(true) { worker = new CameraWorker(0); workerThread = new QThread(); @@ -34,17 +35,11 @@ Camera::Camera() connect(workerThread, &QThread::started, worker, &CameraWorker::onStart); connect(workerThread, &QThread::finished, worker, &CameraWorker::deleteLater); - connect(worker, &CameraWorker::started, this, &Camera::onWorkerStarted); connect(worker, &CameraWorker::newFrameAvailable, this, &Camera::onNewFrameAvailable); connect(worker, &CameraWorker::resProbingFinished, this, &Camera::onResProbingFinished); workerThread->start(); } -void Camera::onWorkerStarted() -{ - worker->probeResolutions(); -} - Camera::~Camera() { workerThread->exit(); @@ -53,6 +48,12 @@ Camera::~Camera() void Camera::subscribe() { + if (needsInit) + { + worker->probeResolutions(); + needsInit = false; + } + if (refcount <= 0) worker->resume(); diff --git a/src/camera.h b/src/camera.h index 7c75a2314..eafcf6c3f 100644 --- a/src/camera.h +++ b/src/camera.h @@ -75,9 +75,9 @@ private: QList resolutions; static Camera* instance; + bool needsInit; private slots: - void onWorkerStarted(); void onNewFrameAvailable(const VideoFrame frame); void onResProbingFinished(QList res);