From fa2bafea8f0cd9fac0864ac23f23c955d5f15b73 Mon Sep 17 00:00:00 2001 From: David Edmundson 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("alignment", config().readEntry("alignment", m_alignment))); + setAlignment((Qt::Alignment)panelConfig.parent().readEntry("alignment", panelConfig.readEntry("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("panelVisibility", config().readEntry("panelVisibility", (int)NormalPanel))); + setVisibilityMode((VisibilityMode)panelConfig.parent().readEntry("panelVisibility", panelConfig.readEntry("panelVisibility", (int)NormalPanel))); m_initCompleted = true; resizePanel(); positionPanel(); -- GitLab