diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 87b29d8662c..4ac8eafdf93 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1972,10 +1972,9 @@ const char *qAccessibleEventString(QAccessible::Event event) Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface) { QDebugStateSaver saver(d); - if (!iface) { - d << "QAccessibleInterface(null)"; - return d; - } + if (!iface) + return d << "QAccessibleInterface(0x0)"; + d.nospace(); d << "QAccessibleInterface(" << Qt::hex << (const void *) iface << Qt::dec; if (iface->isValid()) { diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 65785c406c2..7c5fbdc2d96 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -441,8 +441,8 @@ QStringList QIconTheme::parents() const QDebug operator<<(QDebug debug, const std::unique_ptr &entry) { QDebugStateSaver saver(debug); - debug.noquote() << entry->filename; - return debug; + if (entry) return debug.noquote() << entry->filename; + return debug << "QIconLoaderEngineEntry(0x0)"; } QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index d0c2ddb2b3a..762522daa0f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4055,10 +4055,9 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) QDebug operator<<(QDebug dbg, const QEventPoint *tp) { - if (!tp) { - dbg << "QEventPoint(0x0)"; - return dbg; - } + if (!tp) + return dbg << "QEventPoint(0x0)"; + return operator<<(dbg, *tp); } @@ -4098,10 +4097,9 @@ QDebug operator<<(QDebug dbg, const QEvent *e) { QDebugStateSaver saver(dbg); dbg.nospace(); - if (!e) { - dbg << "QEvent(this = 0x0)"; - return dbg; - } + if (!e) + return dbg << "QEvent(0x0)"; + // More useful event output could be added here const QEvent::Type type = e->type(); bool isMouse = false; diff --git a/src/gui/kernel/qinputdevice.cpp b/src/gui/kernel/qinputdevice.cpp index 25f16c4a7d8..8df730de731 100644 --- a/src/gui/kernel/qinputdevice.cpp +++ b/src/gui/kernel/qinputdevice.cpp @@ -377,10 +377,8 @@ QDebug operator<<(QDebug debug, const QInputDevice *device) debug.noquote(); debug << "QInputDevice("; - if (!device) { - debug << "0)"; - return debug; - } + if (!device) + return debug << "0x0)"; const QInputDevicePrivate *d = QInputDevicePrivate::get(device); diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index c25132dc734..1bf84edf8e9 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1310,7 +1310,7 @@ QDebug operator<<(QDebug debug, const QOpenGLContext *ctx) debug << ", invalid"; } } else { - debug << '0'; + debug << "0x0"; } debug << ')'; return debug; @@ -1324,7 +1324,7 @@ QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg) if (cg) debug << cg->shares(); else - debug << '0'; + debug << "0x0"; debug << ')'; return debug; } diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp index 86d7a88dd1f..dcce354688a 100644 --- a/src/gui/kernel/qpointingdevice.cpp +++ b/src/gui/kernel/qpointingdevice.cpp @@ -726,7 +726,7 @@ QDebug operator<<(QDebug debug, const QPointingDevice *device) if (device->uniqueId().isValid()) debug << " uniqueId=" << Qt::hex << device->uniqueId().numericId() << Qt::dec; } else { - debug << '0'; + debug << "0x0"; } debug << ')'; return debug; diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp index 59c84bd9fb1..8cdcbcaf9b5 100644 --- a/src/opengl/qopengltexture.cpp +++ b/src/opengl/qopengltexture.cpp @@ -4835,7 +4835,7 @@ QDebug operator<<(QDebug debug, const QOpenGLTexture *t) << ", features=" << d->features << ", minificationFilter=" << d->minFilter << ", magnificationFilter=" << d->magFilter << ", wrapMode=" << d->wrapModes[0]; } else { - debug << '0'; + debug << "0x0"; } debug << ')'; return debug; diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 7a6d41e0b32..fc0559e36f2 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -57,7 +57,7 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) if (mimeData->hasUrls()) d << ", urls=" << mimeData->urls(); } else { - d << '0'; + d << "0x0"; } d << ')'; return d; diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index bc09dc7b90e..ed52939c8ee 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -876,7 +876,7 @@ QDebug operator<<(QDebug d, const QPlatformMenuItem *i) if (i) static_cast(i)->formatDebug(d); else - d << '0'; + d << "0x0"; d << ')'; return d; } @@ -915,7 +915,7 @@ QDebug operator<<(QDebug d, const QPlatformMenu *m) static_cast(m)->formatDebug(d); d << ')'; } else { - d << "QPlatformMenu(0)"; + d << "QPlatformMenu(0x0)"; } return d; } @@ -929,7 +929,7 @@ QDebug operator<<(QDebug d, const QPlatformMenuBar *mb) if (mb) static_cast(mb)->formatDebug(d); else - d << '0'; + d << "0x0"; d << ')'; return d; } diff --git a/src/plugins/platforms/windows/qwindowsmimeregistry.cpp b/src/plugins/platforms/windows/qwindowsmimeregistry.cpp index 71faf4fe3b2..99a46d7c9a0 100644 --- a/src/plugins/platforms/windows/qwindowsmimeregistry.cpp +++ b/src/plugins/platforms/windows/qwindowsmimeregistry.cpp @@ -326,7 +326,7 @@ QDebug operator<<(QDebug d, IDataObject *dataObj) } } } else { - d << '0'; + d << "0x0"; } d << ')'; return d; diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 21d15d4e78b..a1e9c7b079c 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -464,7 +464,7 @@ QDebug operator<<(QDebug d, const QWindowsSystemTrayIcon *t) if (t) t->formatDebug(d); else - d << '0'; + d << "0x0"; d << ')'; return d; } diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index b55bea7e305..f33c44d346c 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -11161,10 +11161,8 @@ QDebug operator<<(QDebug debug, const QGraphicsItem *item) QDebugStateSaver saver(debug); debug.nospace(); - if (!item) { - debug << "QGraphicsItem(0)"; - return debug; - } + if (!item) + return debug << "QGraphicsItem(0x0)"; if (const QGraphicsObject *o = item->toGraphicsObject()) debug << o->metaObject()->className(); @@ -11179,7 +11177,7 @@ QDebug operator<<(QDebug debug, const QGraphicsItem *item) debug << ", name=" << w->objectName(); debug << ')'; } else { - debug << "QWidget(0)"; + debug << "QWidget(0x0)"; } } formatGraphicsItemHelper(debug, item); @@ -11192,10 +11190,8 @@ QDebug operator<<(QDebug debug, const QGraphicsObject *item) QDebugStateSaver saver(debug); debug.nospace(); - if (!item) { - debug << "QGraphicsObject(0)"; - return debug; - } + if (!item) + return debug << "QGraphicsObject(0x0)"; debug << item->metaObject()->className() << '(' << static_cast(item); if (!item->objectName().isEmpty()) diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 0ace03b5536..d7ada3a7fde 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -1797,10 +1797,8 @@ QDebug operator<<(QDebug debug, const QGraphicsSceneEvent *event) { QDebugStateSaver saver(debug); debug.nospace(); - if (!event) { - debug << "QGraphicsSceneEvent(0)"; - return debug; - } + if (!event) + return debug << "QGraphicsSceneEvent(0x0)"; const QEvent::Type type = event->type(); switch (type) { diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index 82b4d9ced87..1ae671d9d92 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -1080,6 +1080,10 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) { QDebugStateSaver saver(d); d.nospace(); + + if (!gesture) + return d << "QGesture(0x0)"; + switch (gesture->gestureType()) { case Qt::TapGesture: formatGestureHeader(d, "QTapGesture", gesture); @@ -1148,8 +1152,12 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGestureEvent *gestureEvent) { QDebugStateSaver saver(d); d.nospace(); - d << "QGestureEvent(" << gestureEvent->gestures() << ')'; - return d; + d << "QGestureEvent("; + if (gestureEvent) + d << gestureEvent->gestures(); + else + d << "0x0"; + return d << ')'; } #endif // !QT_NO_DEBUG_STREAM diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 83626b251a7..03dbb730c5c 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -146,8 +146,9 @@ QDebug operator<<(QDebug debug, const QDockAreaLayout &layout) QDebug operator<<(QDebug debug, const QMainWindowLayout *layout) { - debug << layout->layoutState.dockAreaLayout; - return debug; + if (layout) + return debug << layout->layoutState.dockAreaLayout; + return debug << "QMainWindowLayout(0x0)"; } // Use this to dump item lists of all populated main window docks. diff --git a/tests/auto/other/macnativeevents/qnativeevents.cpp b/tests/auto/other/macnativeevents/qnativeevents.cpp index a516fc28d60..121b44eff9c 100644 --- a/tests/auto/other/macnativeevents/qnativeevents.cpp +++ b/tests/auto/other/macnativeevents/qnativeevents.cpp @@ -180,13 +180,13 @@ QString QNativeModifierEvent::toString() const QDebug operator<<(QDebug d, QNativeEvent *e) { - Q_UNUSED(e); - return d << e->toString(); + if (e) + return d << e->toString(); + return d << "QNativeEvent(0x0)"; } QDebug operator<<(QDebug d, const QNativeEvent &e) { - Q_UNUSED(e); return d << e.toString(); } diff --git a/tests/manual/diaglib/debugproxystyle.cpp b/tests/manual/diaglib/debugproxystyle.cpp index 39aad93d176..ad34702baef 100644 --- a/tests/manual/diaglib/debugproxystyle.cpp +++ b/tests/manual/diaglib/debugproxystyle.cpp @@ -14,10 +14,9 @@ QDebug operator<<(QDebug debug, const QStyleOption *option) QDebugStateSaver saver(debug); debug.noquote(); debug.nospace(); - if (!option) { - debug << "QStyleOption(0)"; - return debug; - } + if (!option) + return debug << "QStyleOption(0x0)"; + if (const QStyleOptionViewItem *ivo = qstyleoption_cast(option)) { debug << "QStyleOptionViewItem("; debug << ivo->index;