diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 002c9bcda2..4f85ceb084 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -867,6 +867,19 @@ QDebugStateSaver::~QDebugStateSaver() d->restoreState(); } +/*! + \internal + + Specialization of the primary template in qdebug.h to out-of-line + the common case of QFlags::Int being int. + + Just call the generic version so the two don't get out of sync. +*/ +void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value) +{ + qt_QMetaEnum_flagDebugOperator(debug, sizeofT, value); +} + #ifndef QT_NO_QOBJECT /*! \internal diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index a01dd03a8a..858231e118 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -323,6 +323,27 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) return debug.maybeSpace(); } +Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value); + +template +void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, Int value) +{ + const QDebugStateSaver saver(debug); + debug.resetFormat(); + debug.nospace() << "QFlags(" << hex << showbase; + bool needSeparator = false; + for (uint i = 0; i < sizeofT * 8; ++i) { + if (value & (Int(1) << i)) { + if (needSeparator) + debug << '|'; + else + needSeparator = true; + debug << (Int(1) << i); + } + } + debug << ')'; +} + #if !defined(QT_NO_QOBJECT) && !defined(Q_QDOC) Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name); Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); @@ -357,20 +378,7 @@ template inline QDebug qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags &flags) #endif { - QDebugStateSaver saver(debug); - debug.resetFormat(); - debug.nospace() << "QFlags(" << hex << showbase; - bool needSeparator = false; - for (uint i = 0; i < sizeof(T) * 8; ++i) { - if (flags.testFlag(T(1 << i))) { - if (needSeparator) - debug << '|'; - else - needSeparator = true; - debug << (typename QFlags::Int(1) << i); - } - } - debug << ')'; + qt_QMetaEnum_flagDebugOperator(debug, sizeof(T), typename QFlags::Int(flags)); return debug; }