From 711efc552d65f22b262e049c5a046198377519dc Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 31 May 2016 12:08:10 +0200 Subject: winrt: Fix potential crash when querying for resolutions c84bdf63e4de16586eda3c45d5c3c3b2dc4fe089 introduced a potential crash on Windows Phone as querying for photo resolutions still might return video properties. As a result, querying for ImageEncodingProperties will fail and the function returns no resolution at all causing an assert later on. Instead of checking for the stream type passed to getMediaStreamResolutions we have to check for the property type of the list itself. Task-number: QTBUG-53714 Change-Id: I7bfc48ebf1fef4f9165135af604ce6c91a418438 Reviewed-by: Oliver Wolff --- src/plugins/winrt/qwinrtcameracontrol.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp') diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index 5c41987a0..1eaf27ca5 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -101,7 +101,13 @@ HRESULT getMediaStreamResolutions(IMediaDeviceController *device, ComPtr properties; hr = (*propertiesList)->GetAt(index, &properties); Q_ASSERT_SUCCEEDED(hr); - if (type == MediaStreamType_VideoRecord || type == MediaStreamType_VideoPreview) { + HString propertyType; + hr = properties->get_Type(propertyType.GetAddressOf()); + Q_ASSERT_SUCCEEDED(hr); + + const HStringReference videoRef = HString::MakeReference(L"Video"); + const HStringReference imageRef = HString::MakeReference(L"Image"); + if (propertyType == videoRef) { ComPtr videoProperties; hr = properties.As(&videoProperties); Q_ASSERT_SUCCEEDED(hr); @@ -111,13 +117,10 @@ HRESULT getMediaStreamResolutions(IMediaDeviceController *device, hr = videoProperties->get_Height(&height); Q_ASSERT_SUCCEEDED(hr); resolutions->append(QSize(width, height)); - } else if (type == MediaStreamType_Photo) { + } else if (propertyType == imageRef) { ComPtr imageProperties; hr = properties.As(&imageProperties); - // Asking for Photo also returns video resolutions in addition - // We skip those, as we are only interested in image Type - if (FAILED(hr) || !imageProperties) - continue; + Q_ASSERT_SUCCEEDED(hr); UINT32 width, height; hr = imageProperties->get_Width(&width); Q_ASSERT_SUCCEEDED(hr); -- cgit v1.2.1