QPropertyBindingSourceLocation: fix BiC in source_location ctors

Since the class is exported, both ctors from source_location (std and
experimental) need to be in the DLL, otherwise a Qt built with C++20
(using std::source_location) may break C++17 users that, however, have
experimental::source_location (and therefore expect the DLL to export
it).

This is exactly the same issue we had with QPolygon and
QVector::begin() with and w/o QT_STRICT_ITERTORS, therefore the same
fix applies, with the difference that we don't need a separate TU here
to inject the missing symbols, because both versions can be
overloaded.

[ChangeLog][QtCore][QPropertyBindingSourceLocation] (Windows only)
Fixed a binary-incompatibility where source_location constructors were
missing in the ABI.

Pick-to: 6.3 6.2
Change-Id: I4a514565cceea5f92975eff3a3e936efa5f7d8da
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2022-02-06 10:37:07 +01:00 committed by Allan Sandfeld Jensen
parent 1c9f990332
commit a6657bef40

View File

@ -58,12 +58,14 @@
#endif
#endif
#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION) && __has_include(<experimental/source_location>) && !defined(Q_CLANG_QDOC)
#if __has_include(<experimental/source_location>) && !defined(Q_CLANG_QDOC)
#include <experimental/source_location>
#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION)
#if defined(__cpp_lib_experimental_source_location)
#define QT_SOURCE_LOCATION_NAMESPACE std::experimental
#define QT_PROPERTY_COLLECT_BINDING_LOCATION
#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::experimental::source_location::current())
#endif // defined(__cpp_lib_experimental_source_location)
#endif
#endif
@ -104,6 +106,7 @@ public:
void setValueBypassingBindings(rvalue_ref v) { val = std::move(v); }
};
// ### Qt 7: un-export
struct Q_CORE_EXPORT QPropertyBindingSourceLocation
{
const char *fileName = nullptr;
@ -111,8 +114,17 @@ struct Q_CORE_EXPORT QPropertyBindingSourceLocation
quint32 line = 0;
quint32 column = 0;
QPropertyBindingSourceLocation() = default;
#ifdef QT_PROPERTY_COLLECT_BINDING_LOCATION
constexpr QPropertyBindingSourceLocation(const QT_SOURCE_LOCATION_NAMESPACE::source_location &cppLocation)
#ifdef __cpp_lib_source_location
constexpr QPropertyBindingSourceLocation(const std::source_location &cppLocation)
{
fileName = cppLocation.file_name();
functionName = cppLocation.function_name();
line = cppLocation.line();
column = cppLocation.column();
}
#endif
#ifdef __cpp_lib_experimental_source_location
constexpr QPropertyBindingSourceLocation(const std::experimental::source_location &cppLocation)
{
fileName = cppLocation.file_name();
functionName = cppLocation.function_name();