1
0
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:
sudden6 2015-03-19 12:37:52 +01:00 committed by sudden6
parent 2286d953d9
commit df785e6608

View File

@ -146,7 +146,21 @@ void CameraWorker::subscribe()
if (!cam.isOpened())
{
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
}
}
@ -166,7 +180,20 @@ void CameraWorker::doWork()
if (!cam.isOpened())
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";
return;