Android: Don't call restartViewfinder() for audio only recordings.

Calling restartViewfinder() would try to access m_cameraSession without
checking if it was valid. This change adds guards around the calls to
restartViewfinder(), and one in the function itself.

Task-number: QTBUG-50282
Change-Id: I1f2b4d2b2342bf2dc2b7f28a7bcd00e08a0edb44
Reviewed-by: jian liang <jianliang79@gmail.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
This commit is contained in:
Christian Strømme
2016-01-08 17:46:20 +01:00
committed by Yoann Lopes
parent 9f35d7763e
commit c953ef3910

View File

@@ -219,12 +219,14 @@ void QAndroidCaptureSession::start()
if (!m_mediaRecorder->prepare()) { if (!m_mediaRecorder->prepare()) {
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder.")); emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder."));
if (m_cameraSession)
restartViewfinder(); restartViewfinder();
return; return;
} }
if (!m_mediaRecorder->start()) { if (!m_mediaRecorder->start()) {
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder.")); emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder."));
if (m_cameraSession)
restartViewfinder(); restartViewfinder();
return; return;
} }
@@ -418,6 +420,9 @@ void QAndroidCaptureSession::updateViewfinder()
void QAndroidCaptureSession::restartViewfinder() void QAndroidCaptureSession::restartViewfinder()
{ {
if (!m_cameraSession)
return;
m_cameraSession->camera()->reconnect(); m_cameraSession->camera()->reconnect();
m_cameraSession->camera()->startPreview(); m_cameraSession->camera()->startPreview();
m_cameraSession->setReadyForCapture(true); m_cameraSession->setReadyForCapture(true);