From 31ec0ceb24824aebcf51cf910a5cce5d7c675d17 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 14 Apr 2022 19:36:34 +0000 Subject: [PATCH] Use Toplevel::isDeleted() to resolve Deleted type. Prepares #81 (part 2) Note that the `Unmanaged` type is not explicitly checked - implies `(t->isDeleted() || t->isClient()) == false`. --- src/effects.cpp | 8 ++++---- src/scenes/qpainter/scene_qpainter.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/effects.cpp b/src/effects.cpp index cc48a13519..228e6887be 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1994,7 +1994,7 @@ const EffectWindowGroup *EffectWindowImpl::group() const void EffectWindowImpl::refWindow() { - if (auto d = qobject_cast(toplevel)) { + if (auto d = static_cast(toplevel->isDeleted() ? toplevel : nullptr)) { return d->refWindow(); } Q_UNREACHABLE(); // TODO @@ -2002,7 +2002,7 @@ void EffectWindowImpl::refWindow() void EffectWindowImpl::unrefWindow() { - if (auto d = qobject_cast(toplevel)) { + if (auto d = static_cast(toplevel->isDeleted() ? toplevel : nullptr)) { return d->unrefWindow(); // delays deletion in case } Q_UNREACHABLE(); // TODO @@ -2071,7 +2071,7 @@ TOPLEVEL_HELPER(QUuid, internalId, internalId) if (client) { \ return client->propertyname(); \ } \ - auto deleted = qobject_cast(toplevel); \ + auto deleted = static_cast(toplevel->isDeleted() ? toplevel : nullptr); \ if (deleted) { \ return deleted->propertyname(); \ } \ @@ -2240,7 +2240,7 @@ EffectWindowList EffectWindowImpl::mainWindows() const if (auto client = static_cast(toplevel->isClient() ? toplevel : nullptr)) { return getMainWindows(client); } - if (auto deleted = qobject_cast(toplevel)) { + if (auto deleted = static_cast(toplevel->isDeleted() ? toplevel : nullptr)) { return getMainWindows(deleted); } return {}; diff --git a/src/scenes/qpainter/scene_qpainter.cpp b/src/scenes/qpainter/scene_qpainter.cpp index b57fa29171..0653c30ec2 100644 --- a/src/scenes/qpainter/scene_qpainter.cpp +++ b/src/scenes/qpainter/scene_qpainter.cpp @@ -248,7 +248,7 @@ void SceneQPainter::Window::renderDecorationItem(QPainter *painter, DecorationIt QRect dtr, dlr, drr, dbr; if (auto client = static_cast(toplevel->isClient() ? toplevel : nullptr)) { client->layoutDecorationRects(dlr, dtr, drr, dbr); - } else if (auto deleted = qobject_cast(toplevel)) { + } else if (auto deleted = static_cast(toplevel->isDeleted() ? toplevel : nullptr)) { deleted->layoutDecorationRects(dlr, dtr, drr, dbr); } else { return;