[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: [wayland] Ensure Compositor is destroyed early enough
From:       Martin_Gräßlin <mgraesslin () kde ! org>
Date:       2015-05-27 7:13:42
Message-ID: E1YxVX4-0007ll-Vx () scm ! kde ! org
[Download RAW message or body]

Git commit 604b6d05f533c0cb08c0181559936e2ea5a9a302 by Martin Gräßlin.
Committed on 27/05/2015 at 07:13.
Pushed by graesslin into branch 'master'.

[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.

M  +9    -0    main.cpp
M  +1    -0    main.h
M  +1    -0    main_wayland.cpp

http://commits.kde.org/kwin/604b6d05f533c0cb08c0181559936e2ea5a9a302

diff --git a/main.cpp b/main.cpp
index b19fda3..50700d6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;
diff --git a/main.h b/main.h
index 4a24766..7dafc00 100644
--- a/main.h
+++ b/main.h
@@ -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.
diff --git a/main_wayland.cpp b/main_wayland.cpp
index 206ddfd..d354736 100644
--- a/main_wayland.cpp
+++ b/main_wayland.cpp
@@ -73,6 +73,7 @@ ApplicationWayland::ApplicationWayland(int &argc, char **argv)
 
 ApplicationWayland::~ApplicationWayland()
 {
+    destroyCompositor();
     destroyWorkspace();
     if (x11Connection()) {
         Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic