summaryrefslogtreecommitdiff
blob: 58f3a50c4911a74efce162cc36db1bbb2f072e34 (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
From fa2bafea8f0cd9fac0864ac23f23c955d5f15b73 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Tue, 5 Jan 2021 23:57:19 +0000
Subject: [PATCH] [panel] Fix crash on screen changes

There is an error handling path when we fetch the relevant config()

```
KConfigGroup PanelView::panelConfig(...
{
    if (!containment || !screen) {
        return KConfigGroup();
    }
```

which we indiscrimiately call parent() on.

This patch guards that case, which is presumably screen being
temporarily null.

This code is also Plasma 5.8 compatibility fallback, so arguably we
could get rid of it.

BUG: 425711
---
 shell/panelview.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/shell/panelview.cpp b/shell/panelview.cpp
index 28e86d2d3..991364e97 100644
--- a/shell/panelview.cpp
+++ b/shell/panelview.cpp
@@ -561,7 +561,8 @@ void PanelView::resizePanel()
 
 void PanelView::restore()
 {
-    if (!containment()) {
+    KConfigGroup panelConfig = config();
+    if (!panelConfig.isValid()) {
         return;
     }
 
@@ -572,7 +573,7 @@ void PanelView::restore()
     //but if fails read it from the resolution dependent one as
     //the place for this config key is changed in Plasma 5.9
     //Do NOT use readConfigValueWithFallBack
-    setAlignment((Qt::Alignment)config().parent().readEntry<int>("alignment", config().readEntry<int>("alignment", m_alignment)));
+    setAlignment((Qt::Alignment)panelConfig.parent().readEntry<int>("alignment", panelConfig.readEntry<int>("alignment", m_alignment)));
 
     // All the other values are read from screen independent values,
     // but fallback on the screen independent section, as is the only place
@@ -599,7 +600,7 @@ void PanelView::restore()
     //but if fails read it from the resolution dependent one as
     //the place for this config key is changed in Plasma 5.9
     //Do NOT use readConfigValueWithFallBack
-    setVisibilityMode((VisibilityMode)config().parent().readEntry<int>("panelVisibility", config().readEntry<int>("panelVisibility", (int)NormalPanel)));
+    setVisibilityMode((VisibilityMode)panelConfig.parent().readEntry<int>("panelVisibility", panelConfig.readEntry<int>("panelVisibility", (int)NormalPanel)));
     m_initCompleted = true;
     resizePanel();
     positionPanel();
-- 
GitLab