Commit fa2bafea authored by David Edmundson's avatar David Edmundson
Browse files

[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
parent 45e0a722
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment