From 2bfc010b83974776f03fee011f5b2ab815fdbc2e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 Nov 2014 14:59:28 -0800 Subject: [PATCH] Un-tighten the WinRT specific code out of qfunctions_winrt.h Keep the WinRT specific parts for WinRT only. This commit is a partial reversal of 67c83f329e7fb6fbf5d8e402f42ea8916c34f01c "Tighten Q_OS_WINRT ifdefs in qfunctions_winrt.h", which let the WinRT definitions out too wide. Strictly speaking, the C++ code that uses Microsoft::WRL::ComPtr without the #include is broken. The forward definition is not enough, but since Visual Studio is also broken, two wrongs made a right... (MSVC does not implement two-stage parsing of template code properly). But if you accidentally tried to compile qfunctions_winrt.h with a non-broken compiler, like GCC (MinGW), it would correctly complain. Change-Id: I7591015861d291a82050afe0f4df0cb18b43e23d Reviewed-by: Andrew Knight Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/qfunctions_winrt.h | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h index 04ebda5cfe..c8e082795e 100644 --- a/src/corelib/kernel/qfunctions_winrt.h +++ b/src/corelib/kernel/qfunctions_winrt.h @@ -42,6 +42,23 @@ #include #include +// Convenience macros for handling HRESULT values +#define RETURN_IF_FAILED(msg, ret) \ + if (FAILED(hr)) { \ + qErrnoWarning(hr, msg); \ + ret; \ + } + +#define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr) +#define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK) +#define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false) +#define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return) + +#define Q_ASSERT_SUCCEEDED(hr) \ + Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); + +#ifdef Q_OS_WINRT + QT_BEGIN_NAMESPACE #ifdef QT_BUILD_CORE_LIB @@ -49,7 +66,6 @@ QT_BEGIN_NAMESPACE QT_END_NAMESPACE -#ifdef Q_OS_WINRT // Environment ------------------------------------------------------ errno_t qt_winrt_getenv_s(size_t*, char*, size_t, const char*); @@ -116,24 +132,6 @@ generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *) generate_inline_return_func0(tzset, void) generate_inline_return_func0(_tzset, void) -#endif // Q_OS_WINRT - -// Convenience macros for handling HRESULT values -#define RETURN_IF_FAILED(msg, ret) \ - if (FAILED(hr)) { \ - qErrnoWarning(hr, msg); \ - ret; \ - } - -#define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr) -#define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK) -#define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false) -#define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return) - -#define Q_ASSERT_SUCCEEDED(hr) \ - Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); - - namespace Microsoft { namespace WRL { template class ComPtr; } } namespace QWinRTFunctions { @@ -207,6 +205,8 @@ static inline HRESULT await(const Microsoft::WRL::ComPtr &asyncOp, U *results } // QWinRTFunctions +#endif // Q_OS_WINRT + #endif // Q_OS_WIN #endif // QFUNCTIONS_WINRT_H