From 637d914f9fca73ddc2d7040fee299fb0ad6644d9 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 29 Oct 2021 14:41:35 +0300 Subject: [PATCH] Use QScopedPointer to store decoration object This simplifies memory management. --- src/abstract_client.cpp | 3 +-- src/abstract_client.h | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index dc802d4c4b..a49c9f7797 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -2343,14 +2343,13 @@ void AbstractClient::createDecoration(const QRect &oldGeometry) void AbstractClient::destroyDecoration() { - delete m_decoration.decoration; setDecoration(nullptr); m_decoration.inputRegion = QRegion(); } void AbstractClient::setDecoration(KDecoration2::Decoration *decoration) { - m_decoration.decoration = decoration; + m_decoration.decoration.reset(decoration); Q_EMIT decorationChanged(); } diff --git a/src/abstract_client.h b/src/abstract_client.h index 55c817baef..1f5bad56f9 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -742,10 +742,10 @@ public: // decoration related KDecoration2::Decoration *decoration() { - return m_decoration.decoration; + return m_decoration.decoration.data(); } const KDecoration2::Decoration *decoration() const { - return m_decoration.decoration; + return m_decoration.decoration.data(); } bool isDecorated() const { return m_decoration.decoration != nullptr; @@ -1323,7 +1323,7 @@ private: } m_interactiveMoveResize; struct { - KDecoration2::Decoration *decoration = nullptr; + QScopedPointer decoration; QPointer client; QElapsedTimer doubleClickTimer; QRegion inputRegion;