From 5910adae744182113f4a9117b5c858c77504c052 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 3 Mar 2021 12:22:10 +0100 Subject: [PATCH] QWinRTFunctions::await: Return proper error in case of timeout The await function is still used in other Qt modules which depend on UWP API (like Qt Bluetooth). ERROR_TIMEOUT is a win32 error not an HRESULT so that the check for FAILED(ERROR_TIMEOUT) in "static inline HRESULT await" will not work as expected if we do not use HRESULT_FROM_WIN32. The await function will fail in asyncOp->GetResults but the error message will not be related to a timeout but about a function being called at an unexpected time. Change-Id: Iac46b27f379f80769913d544e32320c77b799b4f Reviewed-by: Miguel Costa Reviewed-by: Alex Blasche Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/qfunctions_winrt_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qfunctions_winrt_p.h b/src/corelib/kernel/qfunctions_winrt_p.h index aa32747bc8e..d98571906e7 100644 --- a/src/corelib/kernel/qfunctions_winrt_p.h +++ b/src/corelib/kernel/qfunctions_winrt_p.h @@ -118,7 +118,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, Awai while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { QCoreApplication::processEvents(); if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; + return HRESULT_FROM_WIN32(ERROR_TIMEOUT); } break; case ProcessThreadEvents: @@ -126,7 +126,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, Awai while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { dispatcher->processEvents(QEventLoop::AllEvents); if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; + return HRESULT_FROM_WIN32(ERROR_TIMEOUT); } break; } @@ -136,7 +136,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr &asyncOp, Awai while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { QThread::yieldCurrentThread(); if (timeout && t.hasExpired(timeout)) - return ERROR_TIMEOUT; + return HRESULT_FROM_WIN32(ERROR_TIMEOUT); } break; }