diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2024-08-07 15:23:39 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-10-09 15:48:15 -0700 |
| commit | 094f7cab54db7f9ce3b62fc1041c33ab30c202f0 (patch) | |
| tree | 3bc41b07c9727448bbce05d7a50b9178058fc943 /src/corelib/io/qdebug.h | |
| parent | 2971dbfe062de6b0be3ed9f251f9506bd45d5854 (diff) | |
QDebug: improve support for printing 64-bit QFlags
Like the 32-bit version, we add an explicitly-exported non-template
overload. And we can call the 64-bit implementation from the 32-bit one
to save in code generation inside QtCore.
Task-number: QTBUG-111926
Change-Id: I8a96935cf6c742259c9dfffd17e9928218333c04
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.h')
| -rw-r--r-- | src/corelib/io/qdebug.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 9b86c8eb1a1..c4be5955c8e 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -526,6 +526,7 @@ inline QDebug operator<<(QDebug debug, const QTaggedPointer<T, Tag> &ptr) Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, qint64 value, const QMetaObject *meta, const char *name); Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, uint value); +Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, quint64 value); template <typename Int> void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, Int value) @@ -556,9 +557,13 @@ inline QDebug operator<<(QDebug debug, Flags flags) using UInt = typename QIntegerForSizeof<T>::Unsigned; #if !defined(QT_NO_QOBJECT) if constexpr (QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<Flags>::Value) { + // if QFlags<T> is a Q_FLAG, we always zero-extend; if not, we need to + // allow it to sign-extend if it is signed (see QMetaEnum::valueToKeys) + using Int = std::conditional_t<QtPrivate::IsQEnumHelper<Flags>::Value, UInt, + std::underlying_type_t<T>>; const QMetaObject *obj = qt_getEnumMetaObject(T()); const char *name = qt_getEnumName(T()); - return qt_QMetaEnum_flagDebugOperator(debug, UInt(flags.toInt()), obj, name); + return qt_QMetaEnum_flagDebugOperator(debug, Int(flags.toInt()), obj, name); } else #endif { |
