summaryrefslogtreecommitdiff
blob: 62cb8a52b6c5457b9fb269bb841533ffc48f3f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From ecf0cc36936f69830a07937b97807ec0ba4d3f41 Mon Sep 17 00:00:00 2001
From: Marco Martin <notmart@gmail.com>
Date: Mon, 10 Jan 2022 09:22:09 +0000
Subject: [PATCH] Don't crash when a screen gets disabled and enabled again

when a screen gets disabled, the containment loses its view, and when gets enabled again,
the process of the old orphaned containment getting a new view causes a plasma crash.
It comes from the wallpaper, which indicates a hierarchy of C++ owned objects
makes the internal one (wallpaper) to not reset correctly its window and have a stray pointer to it.

BUG:447752
---
 .../qml/plasmoid/containmentinterface.cpp     | 21 +++++++++++++++----
 .../qml/plasmoid/containmentinterface.h       |  1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp
index d8a89014c..29a7738ca 100644
--- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp
+++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp
@@ -74,10 +74,6 @@ void ContainmentInterface::init()
     connect(m_activityInfo, &KActivities::Info::nameChanged, this, &ContainmentInterface::activityNameChanged);
     Q_EMIT activityNameChanged();
 
-    if (!m_containment->wallpaper().isEmpty()) {
-        loadWallpaper();
-    }
-
     AppletInterface::init();
 
     // Create the ToolBox
@@ -1162,4 +1158,21 @@ bool ContainmentInterface::isLoading() const
     return loading;
 }
 
+void ContainmentInterface::itemChange(ItemChange change, const ItemChangeData &value)
+{
+    if (change == QQuickItem::ItemSceneChange) {
+        // we have a window: create the representations if needed
+        if (value.window && !m_containment->wallpaper().isEmpty()) {
+            loadWallpaper();
+        } else if (m_wallpaperInterface) {
+            m_wallpaperInterface->deleteLater();
+            m_wallpaperInterface = nullptr;
+            Q_EMIT wallpaperInterfaceChanged();
+        }
+    }
+
+    AppletInterface::itemChange(change, value);
+}
+
+
 #include "moc_containmentinterface.cpp"
diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h
index a91c60c5e..f1276ee80 100644
--- a/src/scriptengines/qml/plasmoid/containmentinterface.h
+++ b/src/scriptengines/qml/plasmoid/containmentinterface.h
@@ -169,6 +169,7 @@ protected:
     void addContainmentActions(QMenu *desktopMenu, QEvent *event);
 
     virtual bool isLoading() const override;
+    void itemChange(ItemChange change, const ItemChangeData &value) override;
 
 Q_SIGNALS:
     /**
-- 
GitLab