core: Make screen area safer in Workspace::clientArea()
If the given output or desktop is not in m_screenAreas, [] operator can crash.
This commit is contained in:
parent
ac97e282fc
commit
411607897f
1 changed files with 9 additions and 3 deletions
|
@ -2243,24 +2243,30 @@ void Workspace::updateClientArea()
|
||||||
QRect Workspace::clientArea(clientAreaOption opt, const Output *output, const VirtualDesktop *desktop) const
|
QRect Workspace::clientArea(clientAreaOption opt, const Output *output, const VirtualDesktop *desktop) const
|
||||||
{
|
{
|
||||||
QRect workArea;
|
QRect workArea;
|
||||||
|
QRect screenArea;
|
||||||
|
|
||||||
const Output *effectiveOutput = output;
|
const Output *effectiveOutput = output;
|
||||||
if (is_multihead) {
|
if (is_multihead) {
|
||||||
effectiveOutput = kwinApp()->platform()->findOutput(screen_number);
|
effectiveOutput = kwinApp()->platform()->findOutput(screen_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect screenArea = m_screenAreas[desktop][effectiveOutput];
|
if (auto desktopIt = m_screenAreas.constFind(desktop); desktopIt != m_screenAreas.constEnd()) {
|
||||||
|
if (auto outputIt = desktopIt->constFind(output); outputIt != desktopIt->constEnd()) {
|
||||||
|
screenArea = *outputIt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (screenArea.isNull()) { // screens may be missing during KWin initialization or screen config changes
|
if (screenArea.isNull()) { // screens may be missing during KWin initialization or screen config changes
|
||||||
screenArea = effectiveOutput->geometry();
|
screenArea = effectiveOutput->geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_multihead) {
|
if (is_multihead) {
|
||||||
workArea = m_workAreas[desktop];
|
workArea = m_workAreas.value(desktop);
|
||||||
if (workArea.isNull()) {
|
if (workArea.isNull()) {
|
||||||
workArea = effectiveOutput->geometry();
|
workArea = effectiveOutput->geometry();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workArea = m_workAreas[desktop];
|
workArea = m_workAreas.value(desktop);
|
||||||
if (workArea.isNull()) {
|
if (workArea.isNull()) {
|
||||||
workArea = QRect(QPoint(0, 0), m_geometry.size());
|
workArea = QRect(QPoint(0, 0), m_geometry.size());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue