From 4c03115882db450a9d1d89e335e3cc562f9aa168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 29 Jun 2015 12:35:38 +0200 Subject: [PATCH] [backends/drm] Fix crash in cleanup of DrmOutput During cleanup the KWayland::OutputInterface is already destroyed before we hit the cleanup code of DrmOutput. Thus guard with a QPointer to not delete twice. --- backends/drm/drm_backend.cpp | 7 ++++++- backends/drm/drm_backend.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backends/drm/drm_backend.cpp b/backends/drm/drm_backend.cpp index c003c9b892..2a4969a6d3 100644 --- a/backends/drm/drm_backend.cpp +++ b/backends/drm/drm_backend.cpp @@ -520,6 +520,7 @@ DrmOutput::~DrmOutput() { hideCursor(); cleanupBlackBuffer(); + delete m_waylandOutput.data(); } void DrmOutput::hideCursor() @@ -608,7 +609,11 @@ void DrmOutput::init(drmModeConnector *connector) initEdid(connector); m_savedCrtc.reset(drmModeGetCrtc(m_backend->fd(), m_crtcId)); blank(); - m_waylandOutput.reset(waylandServer()->display()->createOutput()); + if (!m_waylandOutput.isNull()) { + delete m_waylandOutput.data(); + m_waylandOutput.clear(); + } + m_waylandOutput = waylandServer()->display()->createOutput(); if (!m_edid.eisaId.isEmpty()) { m_waylandOutput->setManufacturer(QString::fromLatin1(m_edid.eisaId)); } else { diff --git a/backends/drm/drm_backend.h b/backends/drm/drm_backend.h index e24b7bff7c..277d9ebb92 100644 --- a/backends/drm/drm_backend.h +++ b/backends/drm/drm_backend.h @@ -22,6 +22,7 @@ along with this program. If not, see . #include "abstract_backend.h" #include +#include #include #include @@ -155,7 +156,7 @@ private: }; Edid m_edid; QScopedPointer<_drmModeCrtc, CrtcCleanup> m_savedCrtc; - QScopedPointer m_waylandOutput; + QPointer m_waylandOutput; }; class DrmBuffer