Checking whether m_topLevel is not null before getting its property

Summary:
From the rest of this method, it is obvious that m_topLevel can
be null in any part of the method - we are checking against it
being null in a few places in the method - both before and after
the affending lines.

Now, there is one place where the check is not applied, and
potentially calls ->window() on the null pointer.

p.s. If there are more places where kwin does clear_or_something(); return;
it could benefit from introducing on_scope_exit and similar tricks - see
Alexandrescu's 'Declarative control flow' presentation.

Reviewers: graesslin

Reviewed By: graesslin

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1346
This commit is contained in:
Ivan Čukić 2016-04-08 09:25:02 +02:00
parent d31e9e88b4
commit 2c95a4e6b9

View file

@ -365,6 +365,10 @@ bool Shadow::updateShadow()
} }
} }
} }
if (!m_topLevel) {
clear();
return false;
}
auto data = Shadow::readX11ShadowProperty(m_topLevel->window()); auto data = Shadow::readX11ShadowProperty(m_topLevel->window());
if (data.isEmpty()) { if (data.isEmpty()) {
clear(); clear();