diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2014-03-07 14:15:13 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-07 14:59:13 +0100 |
commit | 024c8414155e39b64e23066f1335166cee70a9a7 (patch) | |
tree | 537052fa03c6ccdb3ba6898457a8aea6feaa2ce0 | |
parent | 175bdda34701fb3ee9688b40a974a402975b910f (diff) | |
download | qtmultimedia-024c8414155e39b64e23066f1335166cee70a9a7.tar.gz qtmultimedia-024c8414155e39b64e23066f1335166cee70a9a7.tar.bz2 qtmultimedia-024c8414155e39b64e23066f1335166cee70a9a7.zip |
AVFoundation: fix crash when no camera is available on the system.
Change-Id: I0b473babae4d1fae605667957deca21ba1dc0c09
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
-rw-r--r-- | src/plugins/avfoundation/camera/avfvideodevicecontrol.mm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/avfoundation/camera/avfvideodevicecontrol.mm b/src/plugins/avfoundation/camera/avfvideodevicecontrol.mm index d049859c..03736c39 100644 --- a/src/plugins/avfoundation/camera/avfvideodevicecontrol.mm +++ b/src/plugins/avfoundation/camera/avfvideodevicecontrol.mm @@ -66,7 +66,7 @@ int AVFVideoDeviceControl::deviceCount() const QString AVFVideoDeviceControl::deviceName(int index) const { const QList<QByteArray> &devices = AVFCameraSession::availableCameraDevices(); - if (index >= devices.count()) + if (index < 0 || index >= devices.count()) return QString(); return QString::fromUtf8(devices.at(index)); @@ -75,7 +75,7 @@ QString AVFVideoDeviceControl::deviceName(int index) const QString AVFVideoDeviceControl::deviceDescription(int index) const { const QList<QByteArray> &devices = AVFCameraSession::availableCameraDevices(); - if (index >= devices.count()) + if (index < 0 || index >= devices.count()) return QString(); return AVFCameraSession::cameraDeviceInfo(devices.at(index)).description; @@ -93,7 +93,9 @@ int AVFVideoDeviceControl::selectedDevice() const void AVFVideoDeviceControl::setSelectedDevice(int index) { - if (index != m_selectedDevice) { + if (index >= 0 && + index < deviceCount() && + index != m_selectedDevice) { m_dirty = true; m_selectedDevice = index; Q_EMIT selectedDeviceChanged(index); |