diff options
author | Samuel Nevala <samuel.nevala@intopalo.com> | 2015-11-11 10:05:04 +0200 |
---|---|---|
committer | Samuel Nevala <samuel.nevala@intopalo.com> | 2015-11-11 22:12:55 +0000 |
commit | da0b7aea9adae024d5ea885c7e7589de86ce80f8 (patch) | |
tree | e272fe1ad64e66aac2a611dd1741e5c98314fc14 /src/plugins/winrt/qwinrtcameracontrol.cpp | |
parent | b05fac61e0bd3cde6a5a6c37c37ebea01ce8ed29 (diff) | |
download | qtmultimedia-da0b7aea9adae024d5ea885c7e7589de86ce80f8.tar.gz |
winrt: Fix crash when camera unloaded while searching focus.
Return early from focus related methods when async operation reports
that it is write protected.
Change-Id: I41bf9121e7ae431e5158b5e4c43cde582c30dfd7
Task-Id: QTBUG-49347
Reviewed-by: Peng Wu <peng.wu@intopalo.com>
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
Diffstat (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp')
-rw-r--r-- | src/plugins/winrt/qwinrtcameracontrol.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index 7a926ad60..0c9d0e5cb 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -1154,8 +1154,11 @@ bool QWinRTCameraControl::focus() return false; ComPtr<IAsyncAction> op; HRESULT hr = d->focusControl->FocusAsync(&op); - if (HRESULT_CODE(hr) == ERROR_OPERATION_IN_PROGRESS) - return true; + const long errorCode = HRESULT_CODE(hr); + if (errorCode == ERROR_OPERATION_IN_PROGRESS + || errorCode == ERROR_WRITE_PROTECT) { + return false; + } Q_ASSERT_SUCCEEDED(hr); hr = QWinRTFunctions::await(op, QWinRTFunctions::ProcessThreadEvents); Q_ASSERT_SUCCEEDED(hr); @@ -1184,6 +1187,8 @@ bool QWinRTCameraControl::lockFocus() Q_ASSERT_SUCCEEDED(hr); ComPtr<IAsyncAction> op; hr = focusControl2->LockAsync(&op); + if (HRESULT_CODE(hr) == ERROR_WRITE_PROTECT) + return false; Q_ASSERT_SUCCEEDED(hr); return QWinRTFunctions::await(op) == S_OK; } @@ -1198,6 +1203,8 @@ bool QWinRTCameraControl::unlockFocus() Q_ASSERT_SUCCEEDED(hr); ComPtr<IAsyncAction> op; hr = focusControl2->UnlockAsync(&op); + if (HRESULT_CODE(hr) == ERROR_WRITE_PROTECT) + return false; Q_ASSERT_SUCCEEDED(hr); return QWinRTFunctions::await(op) == S_OK; } |