Skip to content

Commit

Permalink
Harden WidgetAttributes debug stream operator
Browse files Browse the repository at this point in the history
The call site may pass in a null-widget, so guard for that.

Pick-to: 6.7
Change-Id: I631cb2fc105bad69faf3daaeac4b893457d27cc1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
  • Loading branch information
torarnv committed Feb 2, 2024
1 parent 90a9452 commit 97c02b8
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/widgets/kernel/qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13214,16 +13214,17 @@ QDebug operator<<(QDebug debug, const WidgetAttributes &attributes)
{
const QDebugStateSaver saver(debug);
debug.nospace();
const QWidget *widget = attributes.widget;
const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount);
const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute"));
debug << '[';
int count = 0;
for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
if (count++)
debug << ',';
debug << me.valueToKey(a);
if (const QWidget *widget = attributes.widget) {
const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount);
const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute"));
int count = 0;
for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
if (count++)
debug << ',';
debug << me.valueToKey(a);
}
}
}
debug << ']';
Expand Down

0 comments on commit 97c02b8

Please sign in to comment.