summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2022-12-06 14:05:54 +0100
committerOliver Wolff <oliver.wolff@qt.io>2023-01-23 18:53:34 +0100
commitb2c1237b4512480a17009afe1981af02c2a9869e (patch)
tree190b58333b194ced7ae43168f140951311f5bc9a
parent76ecff6aebb35f4e39439aab8d18d828c3c8a1fd (diff)
Introduce qt_winrtbase_p.h
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. Pick-to: 6.4 Change-Id: Ic6a80d6d3723af381cf0ecc0f0ab43c2e6839a7d Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/corelib/CMakeLists.txt1
-rw-r--r--src/corelib/platform/windows/qfactorycacheregistration_p.h2
-rw-r--r--src/corelib/platform/windows/qt_winrtbase_p.h32
-rw-r--r--src/corelib/text/qlocale_win.cpp11
-rw-r--r--src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp10
-rw-r--r--src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h3
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp11
7 files changed, 40 insertions, 30 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 1f6e01541fa..e4461e3d7c5 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -1031,6 +1031,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 6a80ce63faa..d0b19b995b4 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 <winrt/base.h>
+#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 <QtCore/qglobal.h>
+
+#if QT_CONFIG(cpp_winrt)
+#include <winrt/base.h>
+#include <QtCore/private/qfactorycacheregistration_p.h>
+// Workaround for Windows SDK bug.
+// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
+namespace winrt::impl
+{
+ template <typename Async>
+ 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 67fac953043..cb8317784f7 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -20,15 +20,8 @@
#endif
#if QT_CONFIG(cpp_winrt)
-# include <winrt/base.h>
-# include <QtCore/private/qfactorycacheregistration_p.h>
-// Workaround for Windows SDK bug.
-// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
-namespace winrt::impl
-{
- template <typename Async>
- auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout);
-}
+# include <QtCore/private/qt_winrtbase_p.h>
+
# include <winrt/Windows.Foundation.h>
# include <winrt/Windows.Foundation.Collections.h>
# include <winrt/Windows.System.UserProfile.h>
diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
index f46dfb88ee9..5b0a91df3ee 100644
--- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
+++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
@@ -9,15 +9,7 @@
#include <mutex>
#if QT_CONFIG(cpp_winrt)
-#include <winrt/base.h>
-#include <QtCore/private/qfactorycacheregistration_p.h>
-// Workaround for Windows SDK bug.
-// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
-namespace winrt::impl
-{
- template <typename Async>
- auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout);
-}
+#include <QtCore/private/qt_winrtbase_p.h>
#include <winrt/Windows.Networking.Connectivity.h>
#endif // QT_CONFIG(cpp_winrt)
diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h
index 548baef2307..d91cd8a4cc6 100644
--- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h
+++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.h
@@ -20,8 +20,7 @@
#include <wrl/wrappers/corewrappers.h>
#if QT_CONFIG(cpp_winrt)
-#include <winrt/base.h>
-#include <QtCore/private/qfactorycacheregistration_p.h>
+#include <QtCore/private/qt_winrtbase_p.h>
#endif
using namespace Microsoft::WRL;
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 6e804c53a02..7535c7a5833 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -43,15 +43,8 @@
#include <algorithm>
#if QT_CONFIG(cpp_winrt)
-# include <winrt/base.h>
-# include <QtCore/private/qfactorycacheregistration_p.h>
-// Workaround for Windows SDK bug.
-// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
-namespace winrt::impl
-{
- template <typename Async>
- auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout);
-}
+# include <QtCore/private/qt_winrtbase_p.h>
+
# include <winrt/Windows.UI.ViewManagement.h>
#endif // QT_CONFIG(cpp_winrt)