[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: Checking whether m_topLevel is not null before getting its property
From:       Ivan Čukić <ivan.cukic () kde ! org>
Date:       2016-04-08 7:25:29
Message-ID: E1aoQnJ-0002jV-Ui () scm ! kde ! org
[Download RAW message or body]

Git commit 2c95a4e6b9add636bb2398e8656268c399f97f19 by Ivan Čukić.
Committed on 08/04/2016 at 07:25.
Pushed by ivan into branch 'master'.

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

M  +4    -0    shadow.cpp

http://commits.kde.org/kwin/2c95a4e6b9add636bb2398e8656268c399f97f19

diff --git a/shadow.cpp b/shadow.cpp
index 65b4080..76792ad 100644
--- a/shadow.cpp
+++ b/shadow.cpp
@@ -365,6 +365,10 @@ bool Shadow::updateShadow()
             }
         }
     }
+    if (!m_topLevel) {
+        clear();
+        return false;
+    }
     auto data = Shadow::readX11ShadowProperty(m_topLevel->window());
     if (data.isEmpty()) {
         clear();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic