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 67c83f329e "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<IAsyncInfo> 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 <andrew.knight@theqtcompany.com>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
This commit is contained in:
Thiago Macieira 2014-11-07 14:59:28 -08:00
parent fe6f4b9ad7
commit 2bfc010b83

View File

@ -42,6 +42,23 @@
#include <QtCore/QAbstractEventDispatcher> #include <QtCore/QAbstractEventDispatcher>
#include <QtCore/qt_windows.h> #include <QtCore/qt_windows.h>
// 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 QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_CORE_LIB #ifdef QT_BUILD_CORE_LIB
@ -49,7 +66,6 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE QT_END_NAMESPACE
#ifdef Q_OS_WINRT
// Environment ------------------------------------------------------ // Environment ------------------------------------------------------
errno_t qt_winrt_getenv_s(size_t*, char*, size_t, const char*); 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)
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 <typename T> class ComPtr; } } namespace Microsoft { namespace WRL { template <typename T> class ComPtr; } }
namespace QWinRTFunctions { namespace QWinRTFunctions {
@ -207,6 +205,8 @@ static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, U *results
} // QWinRTFunctions } // QWinRTFunctions
#endif // Q_OS_WINRT
#endif // Q_OS_WIN #endif // Q_OS_WIN
#endif // QFUNCTIONS_WINRT_H #endif // QFUNCTIONS_WINRT_H