From 8b1b26d5e17c45c2b8db3d16b9fbd2d373626d90 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 18 May 2023 13:36:27 +0300 Subject: tests: Cleanup cursor role objects They should have the same lifetime as the underlying surface Change-Id: I35ad0377a506a4e18e7d4f37691189f636ae54bf Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/client/shared/coreprotocol.cpp | 2 +- tests/auto/client/shared/coreprotocol.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/client/shared/coreprotocol.cpp b/tests/auto/client/shared/coreprotocol.cpp index 8e64adada..15be62ccb 100644 --- a/tests/auto/client/shared/coreprotocol.cpp +++ b/tests/auto/client/shared/coreprotocol.cpp @@ -338,7 +338,7 @@ uint Pointer::sendEnter(Surface *surface, const QPointF &position) uint serial = m_seat->m_compositor->nextSerial(); m_enterSerials << serial; - m_cursorRole = nullptr; // According to the protocol, the pointer image is undefined after enter + m_cursorRole.clear(); // According to the protocol, the pointer image is undefined after enter wl_client *client = surface->resource()->client(); const auto pointerResources = resourceMap().values(client); diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h index 8703fe1d3..e41c719e8 100644 --- a/tests/auto/client/shared/coreprotocol.h +++ b/tests/auto/client/shared/coreprotocol.h @@ -337,7 +337,7 @@ class Pointer : public QObject, public QtWaylandServer::wl_pointer public: explicit Pointer(Seat *seat) : m_seat(seat) {} Surface *cursorSurface(); - CursorRole* m_cursorRole = nullptr; //TODO: cleanup + QPointer m_cursorRole; void send_enter() = delete; uint sendEnter(Surface *surface, const QPointF &position); void send_leave() = delete; @@ -369,6 +369,7 @@ public: explicit CursorRole(Surface *surface) // TODO: needs some more args : m_surface(surface) { + connect(m_surface, &QObject::destroyed, this, &QObject::deleteLater); } static CursorRole *fromSurface(Surface *surface) { return qobject_cast(surface->m_role); } Surface *m_surface = nullptr; -- cgit v1.2.3