diff --git a/autotests/client/test_wayland_blur.cpp b/autotests/client/test_wayland_blur.cpp --- a/autotests/client/test_wayland_blur.cpp +++ b/autotests/client/test_wayland_blur.cpp @@ -44,6 +44,7 @@ void cleanup(); void testCreate(); + void testSurfaceDestroy(); private: KWayland::Server::Display *m_display; @@ -177,5 +178,38 @@ QVERIFY(destroyedSpy.wait()); } +void TestBlur::testSurfaceDestroy() +{ + QSignalSpy serverSurfaceCreated(m_compositorInterface, &KWayland::Server::CompositorInterface::surfaceCreated); + QVERIFY(serverSurfaceCreated.isValid()); + + QScopedPointer surface(m_compositor->createSurface()); + QVERIFY(serverSurfaceCreated.wait()); + + auto serverSurface = serverSurfaceCreated.first().first().value(); + QSignalSpy blurChanged(serverSurface, &KWayland::Server::SurfaceInterface::blurChanged); + QVERIFY(blurChanged.isValid()); + + QScopedPointer blur(m_blurManager->createBlur(surface.data())); + blur->setRegion(m_compositor->createRegion(QRegion(0, 0, 10, 20), nullptr)); + blur->commit(); + surface->commit(KWayland::Client::Surface::CommitFlag::None); + + QVERIFY(blurChanged.wait()); + QCOMPARE(serverSurface->blur()->region(), QRegion(0, 0, 10, 20)); + + // destroy the parent surface + QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); + QVERIFY(surfaceDestroyedSpy.isValid()); + QSignalSpy blurDestroyedSpy(serverSurface->blur(), &QObject::destroyed); + QVERIFY(blurDestroyedSpy.isValid()); + surface.reset(); + QVERIFY(surfaceDestroyedSpy.wait()); + QVERIFY(blurDestroyedSpy.isEmpty()); + // destroy the blur + blur.reset(); + QVERIFY(blurDestroyedSpy.wait()); +} + QTEST_GUILESS_MAIN(TestBlur) #include "test_wayland_blur.moc" diff --git a/src/server/blur_interface.cpp b/src/server/blur_interface.cpp --- a/src/server/blur_interface.cpp +++ b/src/server/blur_interface.cpp @@ -106,14 +106,6 @@ delete blur; return; } - QObject::connect(s, &QObject::destroyed, blur, - [blur] { - if (blur->resource()) { - wl_resource_destroy(blur->resource()); - delete blur; - } - } - ); s->d_func()->setBlur(QPointer(blur)); }