[wayland] Ensure Compositor is destroyed early enough

If startup fails and there is no Workspace the Compositor was destroyed
as a child of Application with the result of being destroyed after the
Wayland server resulting in a crash.

If the Workspace gets created the Compositor will be destroyed by the
Workspace, so there's no need to destroy it early.
This commit is contained in:
Martin Gräßlin 2015-05-27 09:09:05 +02:00
parent d0e5e86a30
commit 604b6d05f5
3 changed files with 11 additions and 0 deletions

View file

@ -423,6 +423,15 @@ void Application::destroyWorkspace()
delete Workspace::self();
}
void Application::destroyCompositor()
{
if (Workspace::self()) {
// compositor is destroyed together with Workspace
return;
}
delete Compositor::self();
}
void Application::updateX11Time(xcb_generic_event_t *event)
{
xcb_timestamp_t time = XCB_TIME_CURRENT_TIME;

1
main.h
View file

@ -166,6 +166,7 @@ protected:
void createCompositor();
void setupEventFilters();
void destroyWorkspace();
void destroyCompositor();
/**
* Inheriting classes should use this method to set the X11 root window
* before accessing any X11 specific code pathes.

View file

@ -73,6 +73,7 @@ ApplicationWayland::ApplicationWayland(int &argc, char **argv)
ApplicationWayland::~ApplicationWayland()
{
destroyCompositor();
destroyWorkspace();
if (x11Connection()) {
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);