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.

Change-Id: Ic6a80d6d3723af381cf0ecc0f0ab43c2e6839a7d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit b2c1237b4512480a17009afe1981af02c2a9869e)
This commit is contained in:
Oliver Wolff 2022-12-06 14:05:54 +01:00
parent f6e3ea4f73
commit 3ae0e8a021
7 changed files with 40 additions and 30 deletions

View File

@ -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

View File

@ -23,7 +23,7 @@
#ifdef QT_USE_FACTORY_CACHE_REGISTRATION
#include <winrt/base.h>
#include "qt_winrtbase_p.h"
QT_BEGIN_NAMESPACE

View File

@ -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

View File

@ -18,15 +18,8 @@
#endif
#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG)
# 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>

View File

@ -8,15 +8,7 @@
#include <mutex>
#ifdef SUPPORTS_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

View File

@ -24,8 +24,7 @@
#endif
#ifdef SUPPORTS_WINRT
#include <winrt/base.h>
#include <QtCore/private/qfactorycacheregistration_p.h>
#include <QtCore/private/qt_winrtbase_p.h>
#endif
using namespace Microsoft::WRL;

View File

@ -46,15 +46,8 @@
#include <algorithm>
#if QT_CONFIG(cpp_winrt) && !defined(Q_CC_CLANG)
# 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>
# define HAS_UISETTINGS 1
#endif