mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Add some error handling in attempt to fix #1240
This should prevent the application from crashing, but there is still no way to tell there is no webcam attached.
This commit is contained in:
parent
2286d953d9
commit
df785e6608
|
@ -146,7 +146,21 @@ void CameraWorker::subscribe()
|
||||||
if (!cam.isOpened())
|
if (!cam.isOpened())
|
||||||
{
|
{
|
||||||
queue.clear();
|
queue.clear();
|
||||||
cam.open(camIndex);
|
bool bSuccess = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bSuccess = cam.open(camIndex);
|
||||||
|
}
|
||||||
|
catch( cv::Exception& e )
|
||||||
|
{
|
||||||
|
qDebug() << "CameraWorker:" << "OpenCV exception caught: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!bSuccess)
|
||||||
|
{
|
||||||
|
qDebug() << "CameraWorker: Could not open camera";
|
||||||
|
}
|
||||||
applyProps(); // restore props
|
applyProps(); // restore props
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +180,20 @@ void CameraWorker::doWork()
|
||||||
if (!cam.isOpened())
|
if (!cam.isOpened())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!cam.read(frame))
|
bool bSuccess = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bSuccess = cam.read(frame);
|
||||||
|
}
|
||||||
|
catch( cv::Exception& e )
|
||||||
|
{
|
||||||
|
qDebug() << "CameraWorker:" << "OpenCV exception caught: " << e.what();;
|
||||||
|
this->clock->stop(); // prevent log spamming
|
||||||
|
qDebug() << "CameraWorker: stopped clock";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bSuccess)
|
||||||
{
|
{
|
||||||
qDebug() << "CameraWorker: Cannot read frame";
|
qDebug() << "CameraWorker: Cannot read frame";
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user