diff options
author | Patrick Stewart <patstew@gmail.com> | 2022-09-06 11:27:15 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-25 14:57:19 +0000 |
commit | 53edbb330d65607c0afa891d925e0d0b71e146e0 (patch) | |
tree | a0ac028d4f559b32810f31dd53ae872d8daa45e1 | |
parent | a3d7619ce61d7afc295b8049f86d562a89cdcb32 (diff) |
Use consteval in QT_PROPERTY_DEFAULT_BINDING_LOCATION
Adds a consteval QPropertyBindingSourceLocation::fromStdSourceLocation
to make sure the QPropertyBindingSourceLocation is created at compile
time.
This is a workaround for what seem to be bugs in MSVC 2019 and 2022,
which otherwise don't regard
QPropertyBindingSourceLocation(std::source_location::current()) as a
constant expression.
Fixes: QTBUG-106277
Change-Id: Ic2379987b278cc0c43c1eb929120c99f5cd95fdf
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 7979665362fe3f86f2ca9cc2a669cce262bd7322)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/corelib/kernel/qproperty.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index fbd838654f..82ef16caba 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -18,7 +18,7 @@ #if defined(__cpp_lib_source_location) #define QT_SOURCE_LOCATION_NAMESPACE std #define QT_PROPERTY_COLLECT_BINDING_LOCATION -#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::source_location::current()) +#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation::fromStdSourceLocation(std::source_location::current()) #endif #endif @@ -86,6 +86,12 @@ struct Q_CORE_EXPORT QPropertyBindingSourceLocation line = cppLocation.line(); column = cppLocation.column(); } + QT_POST_CXX17_API_IN_EXPORTED_CLASS + static consteval QPropertyBindingSourceLocation + fromStdSourceLocation(const std::source_location &cppLocation) + { + return cppLocation; + } #endif #ifdef __cpp_lib_experimental_source_location constexpr QPropertyBindingSourceLocation(const std::experimental::source_location &cppLocation) |