tests: Cleanup cursor role objects

They should have the same lifetime as the underlying surface

Change-Id: I35ad0377a506a4e18e7d4f37691189f636ae54bf
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
David Edmundson 2023-05-18 13:36:27 +03:00
parent 573486001f
commit 5921924fba
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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<CursorRole> 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<CursorRole *>(surface->m_role); }
Surface *m_surface = nullptr;