b83225fcc3
This commit restricts operator<<(QDebug lhs, QVariant rhs) to only work if rhs is actually of type QVariant (instead of any type convertible to QVariant). This is especially important as a) we check in QMetaType whether (slightly simplified) QDebug{} << std::declval<T>() is valid, and if so, register a function which simply uses the operator. b) In QVariant, we ask the metatype system for the contained types registered debug function and then use it. If a type now does not have its own operator<< for QDebug, but is implicitly convertible to QVariant containing itself, this would lead to an infinite recursion, when trying to use qDebug with that type. The registered function in a) would just convert the type to QVariant, and then ask the QVariant to print itself. Disallowing implicit conversions in qDebug in general was considered (i.e. adding template<typename T> operator<<(T) = delete in QDebug ), but discarded as it breaks too much code relying on conversions. Fixes: QTBUG-87122 Change-Id: Ib709297670cbc6cc307efd0dfd8e5b0279df9414 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> |
||
---|---|---|
.. | ||
largefile | ||
qabstractfileengine | ||
qbuffer | ||
qdataurl | ||
qdebug | ||
qdir | ||
qdiriterator | ||
qfile | ||
qfileinfo | ||
qfileselector | ||
qfilesystementry | ||
qfilesystemmetadata | ||
qfilesystemwatcher | ||
qiodevice | ||
qipaddress | ||
qlockfile | ||
qloggingcategory | ||
qloggingregistry | ||
qnodebug | ||
qprocess | ||
qprocess-noapplication | ||
qprocessenvironment | ||
qresourceengine | ||
qsavefile | ||
qsettings | ||
qstandardpaths | ||
qstorageinfo | ||
qtemporarydir | ||
qtemporaryfile | ||
qurl | ||
qurlinternal | ||
qurlquery | ||
.prev_CMakeLists.txt | ||
CMakeLists.txt | ||
io.pro |