From 82005725c2bc8a1e7bf452871f64d5f6a212fb83 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 20 Jun 2023 21:51:30 +0200 Subject: [PATCH] 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 Reviewed-by: Qt CI Bot (cherry picked from commit 46aa713c34c7bc90f3981b3d723591149572203c) Reviewed-by: Marc Mutz --- src/widgets/widgets/qdockarealayout.cpp | 18 ++++++++++-------- src/widgets/widgets/qdockarealayout_p.h | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 6e36d6318ec..0f8a4850041 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -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(this) << "->"; - if (widgetItem) - dbg << "widgetItem(" << widgetItem->widget() << ")"; - else if (subinfo) - dbg << "subInfo(" << subinfo << ")"; - else if (placeHolderItem) - dbg << "placeHolderItem(" << placeHolderItem << ")"; + dbg << "QDockAreaLayoutItem(" << static_cast(&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 diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index b37f22a1ee1..03e84d31446 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -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