QDebug operator for Q_FLAG when the QFlags itself is registered

Currently, IsQEnumHelper<T> returns true also if QFlags<T> is registered
as a Q_FLAG. But this is going to be changed in the next commit.
For the QDebug operator to continue to work even when the QFlags<T> is
registered and not the T, we need to take it into account in the
QEnableIf condition

Change-Id: If1fcffd133aa20ba95a07e2bfaaa308896ab01b0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Olivier Goffart 2015-03-14 12:41:10 +01:00 committed by Olivier Goffart (Woboq GmbH)
parent ebdf991660
commit 59c4024171

View File

@ -275,7 +275,10 @@ operator<<(QDebug dbg, T value)
}
template <class T>
inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
inline typename QtPrivate::QEnableIf<
QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
QDebug>::Type
operator<<(QDebug debug, const QFlags<T> &flags)
{
const QMetaObject *obj = qt_getEnumMetaObject(T());
const char *name = qt_getEnumName(T());
@ -283,7 +286,10 @@ inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>
}
template <class T>
inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
inline typename QtPrivate::QEnableIf<
!QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
QDebug>::Type
operator<<(QDebug debug, const QFlags<T> &flags)
#else // !QT_NO_QOBJECT
template <class T>
inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)