aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Flöser <[email protected]>2019-01-06 17:05:10 +0100
committerMartin Flöser <[email protected]>2019-01-12 07:36:55 +0100
commitc2c92fab518bdd441af2ef8181111b7a49821a50 (patch)
treedd36e15550a030b2bb59193b6d7f6ef0c80fd63d
parent99df3c82f363126e8936cf6cf8a3026b14022e1c (diff)
Ensure the Compositor does not start during termination
Summary: The SceneOpenGLES test was starting to randomly crash on my system. On investigation I observed that there was a graphics reset ("Attempting to reset compositing.") which triggered a delayed restart of the compositor. This even was only processed while waiting for XWayland to terminate. Which resulted in a crash in KWin::getXServerVersion as the xcb connection broke. It makes no sense to setup the compositor again during application shutdown. Thus the dtors set a flag that they are terminating the application and Compositor::setup is checking for it. Test Plan: Test no longer crashes, although it goes through the crashing path Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18015
-rw-r--r--autotests/integration/kwin_wayland_test.cpp1
-rw-r--r--composite.cpp4
-rw-r--r--main.h9
-rw-r--r--main_wayland.cpp1
-rw-r--r--main_x11.cpp1
5 files changed, 16 insertions, 0 deletions
diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp
index d750a53..bd37b5a 100644
--- a/autotests/integration/kwin_wayland_test.cpp
+++ b/autotests/integration/kwin_wayland_test.cpp
@@ -76,6 +76,7 @@ WaylandTestApplication::WaylandTestApplication(OperationMode mode, int &argc, ch
WaylandTestApplication::~WaylandTestApplication()
{
+ setTerminating();
kwinApp()->platform()->setOutputsEnabled(false);
// need to unload all effects prior to destroying X connection as they might do X calls
// also before destroy Workspace, as effects might call into Workspace
diff --git a/composite.cpp b/composite.cpp
index 16b3b6a..a534146 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -156,6 +156,10 @@ Compositor::~Compositor()
void Compositor::setup()
{
+ if (kwinApp()->isTerminating()) {
+ // don't setup while KWin is terminating. An event to restart might be lingering in the event queue due to graphics reset
+ return;
+ }
if (hasScene())
return;
if (m_suspended) {
diff --git a/main.h b/main.h
index 6bde7f2..166c35f 100644
--- a/main.h
+++ b/main.h
@@ -188,6 +188,10 @@ public:
return m_platform;
}
+ bool isTerminating() const {
+ return m_terminating;
+ }
+
static void setupMalloc();
static void setupLocalizedString();
@@ -231,6 +235,10 @@ protected:
}
void destroyAtoms();
+ void setTerminating() {
+ m_terminating = true;
+ }
+
protected:
QString m_originalSessionKey;
static int crashes;
@@ -252,6 +260,7 @@ private:
bool m_useKActivities = true;
#endif
Platform *m_platform = nullptr;
+ bool m_terminating = false;
};
inline static Application *kwinApp()
diff --git a/main_wayland.cpp b/main_wayland.cpp
index ce25dcc..f2cd475 100644
--- a/main_wayland.cpp
+++ b/main_wayland.cpp
@@ -129,6 +129,7 @@ ApplicationWayland::ApplicationWayland(int &argc, char **argv)
ApplicationWayland::~ApplicationWayland()
{
+ setTerminating();
if (!waylandServer()) {
return;
}
diff --git a/main_x11.cpp b/main_x11.cpp
index 765caef..e5e4d2b 100644
--- a/main_x11.cpp
+++ b/main_x11.cpp
@@ -187,6 +187,7 @@ ApplicationX11::ApplicationX11(int &argc, char **argv)
ApplicationX11::~ApplicationX11()
{
+ setTerminating();
destroyCompositor();
destroyWorkspace();
if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) // If there was no --replace (no new WM)