[wayland] Fix cleanup handling on tear down
ASAN righly complained: we need to delete our Wayland objects before we destroy the internal client connection. Solved by better setting parent relationships in the QPA plugin and correctly delete objects in destroy of internal client connection.
This commit is contained in:
parent
51b44f4a87
commit
8175562a7a
3 changed files with 14 additions and 6 deletions
|
@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KWayland/Client/output.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <KWayland/Client/shell.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <KWayland/Server/clientconnection.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
@ -112,8 +113,8 @@ QPlatformWindow *Integration::createPlatformWindow(QWindow *window) const
|
|||
return new QPlatformWindow(window);
|
||||
} else {
|
||||
// don't set window as parent, cause infinite recursion in PlasmaQuick::Dialog
|
||||
auto surface = c->createSurface();
|
||||
return new Window(window, surface, s->createSurface(surface), this);
|
||||
auto surface = c->createSurface(c);
|
||||
return new Window(window, surface, s->createSurface(surface, surface), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +197,7 @@ KWayland::Client::Compositor *Integration::compositor() const
|
|||
auto registry = waylandServer()->internalClientRegistry();
|
||||
const auto c = registry->interface(Registry::Interface::Compositor);
|
||||
if (c.name != 0u) {
|
||||
const_cast<Integration*>(this)->m_compositor = registry->createCompositor(c.name, c.version);
|
||||
const_cast<Integration*>(this)->m_compositor = registry->createCompositor(c.name, c.version, registry);
|
||||
}
|
||||
}
|
||||
return m_compositor;
|
||||
|
@ -209,7 +210,7 @@ KWayland::Client::Shell *Integration::shell() const
|
|||
auto registry = waylandServer()->internalClientRegistry();
|
||||
const auto s = registry->interface(Registry::Interface::Shell);
|
||||
if (s.name != 0u) {
|
||||
const_cast<Integration*>(this)->m_shell = registry->createShell(s.name, s.version);
|
||||
const_cast<Integration*>(this)->m_shell = registry->createShell(s.name, s.version, registry);
|
||||
}
|
||||
}
|
||||
return m_shell;
|
||||
|
|
|
@ -43,6 +43,8 @@ Window::Window(QWindow *window, KWayland::Client::Surface *surface, KWayland::Cl
|
|||
, m_windowId(++s_windowId)
|
||||
, m_integration(integration)
|
||||
{
|
||||
QObject::connect(m_surface, &QObject::destroyed, window, [this] { m_surface = nullptr;});
|
||||
QObject::connect(m_shellSurface, &QObject::destroyed, window, [this] { m_shellSurface = nullptr;});
|
||||
waylandServer()->internalClientConection()->flush();
|
||||
}
|
||||
|
||||
|
@ -103,8 +105,10 @@ void Window::unmap()
|
|||
if (m_shellClient) {
|
||||
m_shellClient->setInternalFramebufferObject(QSharedPointer<QOpenGLFramebufferObject>());
|
||||
}
|
||||
m_surface->attachBuffer(KWayland::Client::Buffer::Ptr());
|
||||
m_surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
||||
if (m_surface) {
|
||||
m_surface->attachBuffer(KWayland::Client::Buffer::Ptr());
|
||||
m_surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
||||
}
|
||||
if (waylandServer()->internalClientConection()) {
|
||||
waylandServer()->internalClientConection()->flush();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/event_queue.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <KWayland/Client/shm_pool.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
// Server
|
||||
#include <KWayland/Server/compositor_interface.h>
|
||||
|
@ -75,6 +76,8 @@ WaylandServer::~WaylandServer() = default;
|
|||
void WaylandServer::destroyInternalConnection()
|
||||
{
|
||||
if (m_internalConnection.client) {
|
||||
delete m_internalConnection.registry;
|
||||
delete m_internalConnection.shm;
|
||||
dispatch();
|
||||
m_internalConnection.client->deleteLater();
|
||||
m_internalConnection.clientThread->quit();
|
||||
|
|
Loading…
Reference in a new issue