x11: Unload effects before destroying Workspace and Compositor

Effects can hold references to closed windows, which can cause problems
after the workspace is destroyed.

This change makes ApplicationX11 unload effects before destroying the
Workspace and the Compositor similar to how it's done in main_wayland.

BUG: 475511
This commit is contained in:
Vlad Zahorodnii 2023-10-23 22:12:37 +03:00
parent 75304afe0f
commit aabc162632

View file

@ -17,6 +17,7 @@
#include "core/outputbackend.h" #include "core/outputbackend.h"
#include "core/session.h" #include "core/session.h"
#include "cursor.h" #include "cursor.h"
#include "effects.h"
#include "outline.h" #include "outline.h"
#include "screenedge.h" #include "screenedge.h"
#include "sm.h" #include "sm.h"
@ -181,6 +182,10 @@ ApplicationX11::ApplicationX11(int &argc, char **argv)
ApplicationX11::~ApplicationX11() ApplicationX11::~ApplicationX11()
{ {
setTerminating(); setTerminating();
// need to unload all effects before destroying Workspace, as effects might call into Workspace
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->unloadAllEffects();
}
destroyPlugins(); destroyPlugins();
destroyColorManager(); destroyColorManager();
destroyWorkspace(); destroyWorkspace();
@ -238,6 +243,10 @@ PlatformCursorImage ApplicationX11::cursorImage() const
void ApplicationX11::lostSelection() void ApplicationX11::lostSelection()
{ {
sendPostedEvents(); sendPostedEvents();
// need to unload all effects before destroying Workspace, as effects might call into Workspace
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->unloadAllEffects();
}
destroyPlugins(); destroyPlugins();
destroyColorManager(); destroyColorManager();
destroyWorkspace(); destroyWorkspace();