[wayland] Emit signal before x11 connection gets destroyed

Used in Compositor to destroy the cm_selection. This would crash
otherwise as it calls into xcb after Xwayland is destroyed.
This commit is contained in:
Martin Gräßlin 2015-11-12 15:13:42 +01:00
parent f2bdb4818a
commit 240e7ba337
4 changed files with 9 additions and 0 deletions

View file

@ -62,6 +62,7 @@ WaylandTestApplication::~WaylandTestApplication()
if (x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
destroyAtoms();
emit x11ConnectionAboutToBeDestroyed();
xcb_disconnect(x11Connection());
setX11Connection(nullptr);
}

View file

@ -128,6 +128,12 @@ Compositor::Compositor(QObject* workspace)
}
}, Qt::QueuedConnection
);
connect(kwinApp(), &Application::x11ConnectionAboutToBeDestroyed, this,
[this] {
delete cm_selection;
cm_selection = nullptr;
}
);
} else {
// delay the call to setup by one event cycle
// The ctor of this class is invoked from the Workspace ctor, that means before

1
main.h
View file

@ -152,6 +152,7 @@ public:
Q_SIGNALS:
void x11ConnectionChanged();
void x11ConnectionAboutToBeDestroyed();
void workspaceCreated();
void screensCreated();
void virtualTerminalCreated();

View file

@ -86,6 +86,7 @@ ApplicationWayland::~ApplicationWayland()
if (x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
destroyAtoms();
emit x11ConnectionAboutToBeDestroyed();
xcb_disconnect(x11Connection());
setX11Connection(nullptr);
}