From 1ff218667c323d1d47aeb7495bee2a7e3995380e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 11 Oct 2024 08:56:56 +0000 Subject: [PATCH] effect: Prevent QJSEngine garbage collecting EffectWindow EffectWindow has no parent so QJSEngine can garbage collect an instance if it's returned by a function marked with Q_INVOKABLE. CCBUG: 487771 (cherry picked from commit 8a5a9f7c12884439aac013633070d9a36820ac79) Co-authored-by: Vlad Zahorodnii --- src/effect/effectwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/effect/effectwindow.cpp b/src/effect/effectwindow.cpp index b66859d3ce..919d86bcb7 100644 --- a/src/effect/effectwindow.cpp +++ b/src/effect/effectwindow.cpp @@ -20,6 +20,8 @@ #include "x11window.h" #endif +#include + namespace KWin { @@ -47,6 +49,8 @@ EffectWindow::Private::Private(EffectWindow *q, WindowItem *windowItem) EffectWindow::EffectWindow(WindowItem *windowItem) : d(new Private(this, windowItem)) { + QJSEngine::setObjectOwnership(this, QJSEngine::CppOwnership); + // Deleted windows are not managed. So, when windowClosed signal is // emitted, effects can't distinguish managed windows from unmanaged // windows(e.g. combo box popups, popup menus, etc). Save value of the