From 73162e8faeaf8697d8a1e4ac9d0aa801df050e7e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 29 Sep 2021 11:51:23 +0300 Subject: [PATCH] Store Toplevel surface using QPointer This makes Toplevel::setSurface() simpler. --- src/toplevel.cpp | 8 +++++--- src/toplevel.h | 8 ++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/toplevel.cpp b/src/toplevel.cpp index 091f1322a9..970d4b480f 100644 --- a/src/toplevel.cpp +++ b/src/toplevel.cpp @@ -609,6 +609,11 @@ void Toplevel::setSkipCloseAnimation(bool set) Q_EMIT skipCloseAnimationChanged(); } +KWaylandServer::SurfaceInterface *Toplevel::surface() const +{ + return m_surface; +} + void Toplevel::setSurface(KWaylandServer::SurfaceInterface *surface) { if (m_surface == surface) { @@ -616,9 +621,6 @@ void Toplevel::setSurface(KWaylandServer::SurfaceInterface *surface) } m_surface = surface; m_pendingSurfaceId = 0; - connect(m_surface, &KWaylandServer::SurfaceInterface::destroyed, this, [this]() { - m_surface = nullptr; - }); Q_EMIT surfaceChanged(); } diff --git a/src/toplevel.h b/src/toplevel.h index 122e92014b..b25891b915 100644 --- a/src/toplevel.h +++ b/src/toplevel.h @@ -18,6 +18,7 @@ // Qt #include #include +#include #include #include // c++ @@ -718,7 +719,7 @@ private: AbstractOutput *m_output = nullptr; bool m_skipCloseAnimation; quint32 m_pendingSurfaceId = 0; - KWaylandServer::SurfaceInterface *m_surface = nullptr; + QPointer m_surface; // when adding new data members, check also copyToDeleted() qreal m_screenScale = 1.0; qreal m_opacity = 1.0; @@ -963,11 +964,6 @@ inline quint32 Toplevel::pendingSurfaceId() const return m_pendingSurfaceId; } -inline KWaylandServer::SurfaceInterface *Toplevel::surface() const -{ - return m_surface; -} - inline const QSharedPointer &Toplevel::internalFramebufferObject() const { return m_internalFBO;