Harden WidgetAttributes debug stream operator

The call site may pass in a null-widget, so guard for that.

Change-Id: I631cb2fc105bad69faf3daaeac4b893457d27cc1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 97c02b80ae28d9bdc4e01980296e0db67f194f81)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2024-02-02 11:22:50 +01:00
parent 5511f64ded
commit 68a8a8b309

View File

@ -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 << ']';