From 3ae0e8a0214d73b970f95ee1b16275355f068b69 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 6 Dec 2022 14:05:54 +0100 Subject: [PATCH] Introduce qt_winrtbase_p.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to a bug in earlier Windows SDKs developers have copy paste a workaround whenever they are including winrt/base.h. In addition to that our usage winrt API also forces them to include qfactorycacheregistration_p.h whenever they include that file. To make things easier all that magic can now be done with one single include of qt_winrtbase_p.h. Change-Id: Ic6a80d6d3723af381cf0ecc0f0ab43c2e6839a7d Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Oliver Wolff (cherry picked from commit b2c1237b4512480a17009afe1981af02c2a9869e) --- src/corelib/CMakeLists.txt | 1 + .../windows/qfactorycacheregistration_p.h | 2 +- src/corelib/platform/windows/qt_winrtbase_p.h | 32 +++++++++++++++++++ src/corelib/text/qlocale_win.cpp | 11 ++----- .../qnetworklistmanagerevents.cpp | 10 +----- .../qnetworklistmanagerevents.h | 3 +- .../platforms/windows/qwindowstheme.cpp | 11 ++----- 7 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 src/corelib/platform/windows/qt_winrtbase_p.h diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 1233f3290b5..40eb0826aa4 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -976,6 +976,7 @@ qt_internal_extend_target(Core CONDITION WIN32 SOURCES platform/windows/qfactorycacheregistration_p.h platform/windows/qfactorycacheregistration.cpp + platform/windows/qt_winrtbase_p.h ) qt_internal_extend_target(Core CONDITION HAIKU AND NOT ANDROID diff --git a/src/corelib/platform/windows/qfactorycacheregistration_p.h b/src/corelib/platform/windows/qfactorycacheregistration_p.h index db1582e94be..f450062fc4e 100644 --- a/src/corelib/platform/windows/qfactorycacheregistration_p.h +++ b/src/corelib/platform/windows/qfactorycacheregistration_p.h @@ -23,7 +23,7 @@ #ifdef QT_USE_FACTORY_CACHE_REGISTRATION -#include +#include "qt_winrtbase_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/platform/windows/qt_winrtbase_p.h b/src/corelib/platform/windows/qt_winrtbase_p.h new file mode 100644 index 00000000000..36551b7faf1 --- /dev/null +++ b/src/corelib/platform/windows/qt_winrtbase_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QT_WINRTBASE_P_H +#define QT_WINRTBASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#if QT_CONFIG(cpp_winrt) +#include +#include +// Workaround for Windows SDK bug. +// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 +namespace winrt::impl +{ + template + auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout); +} +#endif // QT_CONFIG(cpp/winrt) + +#endif // QT_WINRTBASE_P_H diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index f68c0584e7b..270a4833a34 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -18,15 +18,8 @@ #endif #if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) -# include -# include -// Workaround for Windows SDK bug. -// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 -namespace winrt::impl -{ - template - auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout); -} +# include + # include # include # include diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp index 90f63166f3d..a4b1f23b9c5 100644 --- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp +++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp @@ -8,15 +8,7 @@ #include #ifdef SUPPORTS_WINRT -#include -#include -// Workaround for Windows SDK bug. -// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 -namespace winrt::impl -{ - template - auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout); -} +#include #include #endif diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h index 85042c611a2..8480940110f 100644 --- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h +++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h @@ -24,8 +24,7 @@ #endif #ifdef SUPPORTS_WINRT -#include -#include +#include #endif using namespace Microsoft::WRL; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 55ccfcc8f42..f622cf7b057 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -46,15 +46,8 @@ #include #if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG) -# include -# include -// Workaround for Windows SDK bug. -// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 -namespace winrt::impl -{ - template - auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout); -} +# include + # include # define HAS_UISETTINGS 1 #endif