Commit 41160789 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

core: Make screen area safer in Workspace::clientArea()

If the given output or desktop is not in m_screenAreas, [] operator can
crash.
parent ac97e282
Pipeline #190875 passed with stage
in 37 minutes and 43 seconds
......@@ -2243,24 +2243,30 @@ void Workspace::updateClientArea()
QRect Workspace::clientArea(clientAreaOption opt, const Output *output, const VirtualDesktop *desktop) const
{
QRect workArea;
QRect screenArea;
const Output *effectiveOutput = output;
if (is_multihead) {
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
screenArea = effectiveOutput->geometry();
}
if (is_multihead) {
workArea = m_workAreas[desktop];
workArea = m_workAreas.value(desktop);
if (workArea.isNull()) {
workArea = effectiveOutput->geometry();
}
} else {
workArea = m_workAreas[desktop];
workArea = m_workAreas.value(desktop);
if (workArea.isNull()) {
workArea = QRect(QPoint(0, 0), m_geometry.size());
}
......
Supports Markdown
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