From 55980513e7b6780143d3c3b8906ac56aa97ca662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 24 Apr 2012 21:10:16 +0200 Subject: [PATCH] Fix regressions related to stacking order changes The change to have stacking order containing Toplevel inestead of Clients (431aad6d6994695e72697fcc3299ec2cb6f0684e) introduced possible crashers as recognized in: http://git.reviewboard.kde.org/r/104519/#review12714 This change fixes these issues by adding missing null pointer checks after casting to Client. BUG: 298669 FIXED-IN: 4.9.0 REVIEW: 104714 --- layers.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layers.cpp b/layers.cpp index 589c940be5..487e4e496e 100644 --- a/layers.cpp +++ b/layers.cpp @@ -418,9 +418,9 @@ void Workspace::restack(Client* c, Client* under) assert(unconstrained_stacking_order.contains(under)); if (!Client::belongToSameApplication(under, c)) { // put in the stacking order below _all_ windows belonging to the active application - Client *other = 0; - for (int i = 0; i < unconstrained_stacking_order.size(); ++i) { // TODO ignore topmenus? - if (Client::belongToSameApplication(under, (other = qobject_cast(unconstrained_stacking_order.at(i))))) { + for (int i = 0; i < unconstrained_stacking_order.size(); ++i) { + Client *other = qobject_cast(unconstrained_stacking_order.at(i)); + if (other && Client::belongToSameApplication(under, other)) { under = (c == other) ? 0 : other; break; } @@ -767,7 +767,7 @@ void Client::restackWindow(Window above, int detail, NET::RequestSource src, Tim } Client *c = qobject_cast(*it); - if (!( (*it)->isNormalWindow() && c->isShown(true) && + if (!c || !( (*it)->isNormalWindow() && c->isShown(true) && (*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnScreen(screen()) )) continue; // irrelevant clients