summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2021-10-12 09:21:03 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-12 22:26:14 +0000
commit54e212fdb63a4b4e8b2b77cb087d54a5c4a64aea (patch)
tree6f3afdc9c1cbca2cbe323308e87ce1974c0a8167
parenta6e1c319a0628bcea87a0a5ad6b9b4cfa4efe0ba (diff)
Guard WinRT API code for clang-cl
It is unsupported with clang-cl and breaks the build. This is a fixup for: 51e8d3592a Let QLocale::uiLanguages() use WinRT API when possible Task-number: QTBUG-94341 Change-Id: Icf32339e81d67d4c119b7fb8d8d834c744b9ead0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d24651d548d6f86f988dd28ccfe2370f4af75765) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/CMakeLists.txt3
-rw-r--r--src/corelib/text/qlocale_win.cpp8
2 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index eda2c8dea7..f0ff76e007 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -785,7 +785,8 @@ qt_internal_extend_target(Core CONDITION WIN32
text/qlocale_win.cpp
)
-qt_internal_extend_target(Core CONDITION WIN32 AND MSVC
+# On MS-Win, clang has two flavors, one of which immitates MSVC (so claims to be it)
+qt_internal_extend_target(Core CONDITION WIN32 AND MSVC AND NOT CLANG
LIBRARIES
runtimeobject
)
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 1278b73f02..ee3aac13ce 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -51,7 +51,7 @@
# include <time.h>
#endif
-#if defined(Q_CC_MSVC)
+#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
# include <winrt/base.h>
// Workaround for Windows SDK bug.
// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
@@ -63,7 +63,7 @@ namespace winrt::impl
# include <winrt/Windows.Foundation.h>
# include <winrt/Windows.Foundation.Collections.h>
# include <winrt/Windows.System.UserProfile.h>
-#endif // defined(Q_CC_MSVC)
+#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
QT_BEGIN_NAMESPACE
@@ -631,7 +631,7 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
QStringList result;
-#if defined(Q_CC_MSVC) // msvc supports WinRT calls
+#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) // msvc supports WinRT calls
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::System::UserProfile;
@@ -640,7 +640,7 @@ QVariant QSystemLocalePrivate::uiLanguages()
result << QString::fromStdString(winrt::to_string(lang));
if (!result.isEmpty())
return result; // else just fall back to WIN32 API implementation
-#endif // defined(Q_CC_MSVC)
+#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
// mingw and clang still have to use Win32 API
unsigned long cnt = 0;
QVarLengthArray<wchar_t, 64> buf(64);