From 4cc008c9d278756acb70ca06b601b4caff7d896b Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 29 May 2018 12:23:20 +0200 Subject: [PATCH] [autotests] Fix surface destroy test Summary: Interfaces must be cleaned up correctly and client proxys destroyed. Otherwise we get a memory corruption. Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D13190 --- .../autotests/client/test_wayland_surface.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index e106f4c2cf..476c72c0c0 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -71,12 +71,12 @@ private Q_SLOTS: private: KWayland::Server::Display *m_display; KWayland::Server::CompositorInterface *m_compositorInterface; - KWayland::Server::IdleInhibitManagerInterface *m_idleInhibitInterface = nullptr; + KWayland::Server::IdleInhibitManagerInterface *m_idleInhibitInterface; KWayland::Client::ConnectionThread *m_connection; KWayland::Client::Compositor *m_compositor; KWayland::Client::ShmPool *m_shm; KWayland::Client::EventQueue *m_queue; - KWayland::Client::IdleInhibitManager *m_idleInhibitManager = nullptr; + KWayland::Client::IdleInhibitManager *m_idleInhibitManager; QThread *m_thread; }; @@ -190,6 +190,9 @@ void TestWaylandSurface::cleanup() delete m_compositorInterface; m_compositorInterface = nullptr; + delete m_idleInhibitInterface; + m_idleInhibitInterface = nullptr; + delete m_display; m_display = nullptr; } @@ -779,13 +782,19 @@ void TestWaylandSurface::testDestroy() connect(m_connection, &ConnectionThread::connectionDied, m_compositor, &Compositor::destroy); connect(m_connection, &ConnectionThread::connectionDied, m_shm, &ShmPool::destroy); connect(m_connection, &ConnectionThread::connectionDied, m_queue, &EventQueue::destroy); + connect(m_connection, &ConnectionThread::connectionDied, m_idleInhibitManager, &IdleInhibitManager::destroy); QVERIFY(s->isValid()); QSignalSpy connectionDiedSpy(m_connection, SIGNAL(connectionDied())); QVERIFY(connectionDiedSpy.isValid()); + + delete m_compositorInterface; + m_compositorInterface = nullptr; + delete m_idleInhibitInterface; + m_idleInhibitInterface = nullptr; delete m_display; m_display = nullptr; - m_compositorInterface = nullptr; + QVERIFY(connectionDiedSpy.wait()); // now the Surface should be destroyed;