From 566223b190d5cd471d47bdd25cdf009fa01073f2 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 16 Aug 2021 03:11:30 +0200 Subject: [PATCH] platforms/drm: fix crashing debug operator --- src/plugins/platforms/drm/drm_object.cpp | 10 ++++++++-- src/plugins/platforms/drm/drm_object.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/drm/drm_object.cpp b/src/plugins/platforms/drm/drm_object.cpp index 4f6ca38ad2..8f09ef4277 100644 --- a/src/plugins/platforms/drm/drm_object.cpp +++ b/src/plugins/platforms/drm/drm_object.cpp @@ -339,7 +339,13 @@ void DrmObject::Property::initEnumMap(drmModePropertyRes *prop) } -QDebug& operator<<(QDebug& s, const KWin::DrmObject *obj) +QDebug operator<<(QDebug s, const KWin::DrmObject *obj) { - return s.nospace() << "DrmObject(" << obj->id() << ", gpu: "<< obj->gpu() << ')'; + QDebugStateSaver saver(s); + if (obj) { + s.nospace() << "DrmObject(id=" << obj->id() << ", gpu="<< obj->gpu() << ')'; + } else { + s << "DrmObject(0x0)"; + } + return s; } diff --git a/src/plugins/platforms/drm/drm_object.h b/src/plugins/platforms/drm/drm_object.h index 6a520d858c..9ead3af331 100644 --- a/src/plugins/platforms/drm/drm_object.h +++ b/src/plugins/platforms/drm/drm_object.h @@ -211,4 +211,4 @@ private: } -QDebug& operator<<(QDebug& stream, const KWin::DrmObject*); +QDebug operator<<(QDebug stream, const KWin::DrmObject*);