Commit 3a7bce69 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Explicitly destroy plugins

A plugin may need to access kwinApp() or kwinApp()->platform() during
tear down, but the problem is that plugins are destroyed after the
kwinApp() object. The plugin manager must be destroyed explicitly while
the application is still valid to ensure that no crash will occur
during compositor teardown.
parent 02c3dfb8
......@@ -79,6 +79,7 @@ WaylandTestApplication::~WaylandTestApplication()
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
}
destroyPlugins();
delete m_xwayland;
m_xwayland = nullptr;
destroyWorkspace();
......@@ -131,7 +132,7 @@ void WaylandTestApplication::performStartup()
// try creating the Wayland Backend
createInput();
createBackend();
PluginManager::create(this);
createPlugins();
}
void WaylandTestApplication::createBackend()
......
......@@ -17,6 +17,7 @@
#include "input.h"
#include "logind.h"
#include "options.h"
#include "pluginmanager.h"
#include "screens.h"
#include "screenlockerwatcher.h"
#include "sm.h"
......@@ -296,6 +297,11 @@ void Application::createOptions()
options = new Options;
}
void Application::createPlugins()
{
PluginManager::create(this);
}
void Application::installNativeX11EventFilter()
{
installNativeEventFilter(m_eventFilter.data());
......@@ -316,6 +322,11 @@ void Application::destroyCompositor()
delete Compositor::self();
}
void Application::destroyPlugins()
{
delete PluginManager::self();
}
void Application::updateX11Time(xcb_generic_event_t *event)
{
xcb_timestamp_t time = XCB_TIME_CURRENT_TIME;
......
......@@ -210,10 +210,12 @@ protected:
void createWorkspace();
void createAtoms();
void createOptions();
void createPlugins();
void installNativeX11EventFilter();
void removeNativeX11EventFilter();
void destroyWorkspace();
void destroyCompositor();
void destroyPlugins();
/**
* Inheriting classes should use this method to set the X11 root window
* before accessing any X11 specific code pathes.
......
......@@ -14,7 +14,6 @@
// kwin
#include "platform.h"
#include "effects.h"
#include "pluginmanager.h"
#include "tabletmodemanager.h"
#include "wayland_server.h"
......@@ -129,6 +128,7 @@ ApplicationWayland::~ApplicationWayland()
if (effects) {
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
}
destroyPlugins();
delete m_xwayland;
m_xwayland = nullptr;
destroyWorkspace();
......@@ -158,7 +158,7 @@ void ApplicationWayland::performStartup()
InputMethod::create(this);
createBackend();
TabletModeManager::create(this);
PluginManager::create(this);
createPlugins();
}
void ApplicationWayland::createBackend()
......
......@@ -13,7 +13,6 @@
#include <config-kwin.h>
#include "platform.h"
#include "pluginmanager.h"
#include "sm.h"
#include "workspace.h"
#include "xcbutils.h"
......@@ -191,6 +190,7 @@ void ApplicationX11::setReplace(bool replace)
void ApplicationX11::lostSelection()
{
sendPostedEvents();
destroyPlugins();
destroyCompositor();
destroyWorkspace();
// Remove windowmanager privileges
......@@ -249,7 +249,7 @@ void ApplicationX11::performStartup()
connect(platform(), &Platform::screensQueried, this,
[this] {
createWorkspace();
PluginManager::create(this);
createPlugins();
Xcb::sync(); // Trigger possible errors, there's still a chance to abort
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment