QDockAreaLayoutInfo: fix QDebug stream operator

The existing implementation as a member function QDALI::op<<(QDebug)
cannot possibly work, as the implicit `this` argument comes first in
this case, while for streaming operators, the QDebug object must come
first.

Rewrite as a hidden friend and apply QT_NO_DEBUG_STREAM protection as
a drive-by.

Amends faec937756810bbc478da677efb0dca4531a6222.

Task-number: QTBUG-114542
Task-number: QTBUG-112491
Change-Id: Ida400d335491896ec49f2c0f9601a8430eebcd4d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 46aa713c34c7bc90f3981b3d723591149572203c)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Marc Mutz 2023-06-20 21:51:30 +02:00
parent 22dc39a8d7
commit 82005725c2
2 changed files with 13 additions and 9 deletions

View File

@ -171,20 +171,22 @@ QDockAreaLayoutItem
return *this;
}
QDebug QDockAreaLayoutItem::operator<<(QDebug dbg)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDockAreaLayoutItem &item)
{
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg << "QDockAreaLayoutItem(" << static_cast<void *>(this) << "->";
if (widgetItem)
dbg << "widgetItem(" << widgetItem->widget() << ")";
else if (subinfo)
dbg << "subInfo(" << subinfo << ")";
else if (placeHolderItem)
dbg << "placeHolderItem(" << placeHolderItem << ")";
dbg << "QDockAreaLayoutItem(" << static_cast<const void *>(&item) << "->";
if (item.widgetItem)
dbg << "widgetItem(" << item.widgetItem->widget() << ")";
else if (item.subinfo)
dbg << "subInfo(" << item.subinfo << ")";
else if (item.placeHolderItem)
dbg << "placeHolderItem(" << item.placeHolderItem << ")";
dbg << ")";
return dbg;
}
#endif // QT_NO_DEBUG_STREAM
/******************************************************************************
** QDockAreaLayoutInfo

View File

@ -73,7 +73,9 @@ struct Q_AUTOTEST_EXPORT QDockAreaLayoutItem
int pos;
int size;
uint flags;
QDebug operator<<(QDebug dbg);
#ifndef QT_NO_DEBUG_STREAM
friend Q_AUTOTEST_EXPORT QDebug operator<<(QDebug dbg, const QDockAreaLayoutItem &item);
#endif
};
class Q_AUTOTEST_EXPORT QPlaceHolderItem