Avoid deleting ourselves midway through updateShadow
Summary: If updating a shadow means that there should be no shadow, shadow ends up deleting itself midway through the method. It's cleaner and safer to leave that to the caller. This new change matches the existing documentation for Shadow::updateShadow which states > In case the Property has been withdrawn the method returns @c false. > In that case the owner should delete the Shadow. Test Plan: Created an ASAN of kwin Relevant testMaximised no longer fails Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D17380
This commit is contained in:
parent
90a26e2e8d
commit
576c667124
2 changed files with 4 additions and 15 deletions
14
shadow.cpp
14
shadow.cpp
|
@ -331,15 +331,6 @@ void Shadow::buildQuads()
|
|||
|
||||
bool Shadow::updateShadow()
|
||||
{
|
||||
auto clear = [this] {
|
||||
if (m_topLevel && m_topLevel->shadow()) {
|
||||
auto w = m_topLevel->effectWindow();
|
||||
// this also deletes the shadow
|
||||
w->sceneWindow()->updateShadow(nullptr);
|
||||
emit m_topLevel->shadowChanged();
|
||||
}
|
||||
};
|
||||
|
||||
if (!m_topLevel) {
|
||||
return false;
|
||||
}
|
||||
|
@ -348,12 +339,10 @@ bool Shadow::updateShadow()
|
|||
if (AbstractClient *c = qobject_cast<AbstractClient*>(m_topLevel)) {
|
||||
if (c->decoration()) {
|
||||
if (init(c->decoration())) {
|
||||
emit m_topLevel->shadowChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -361,7 +350,6 @@ bool Shadow::updateShadow()
|
|||
if (m_topLevel && m_topLevel->surface()) {
|
||||
if (const auto &s = m_topLevel->surface()->shadow()) {
|
||||
if (init(s)) {
|
||||
emit m_topLevel->shadowChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -370,12 +358,10 @@ bool Shadow::updateShadow()
|
|||
|
||||
auto data = Shadow::readX11ShadowProperty(m_topLevel->window());
|
||||
if (data.isEmpty()) {
|
||||
clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
init(data);
|
||||
emit m_topLevel->shadowChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -336,7 +336,10 @@ void Toplevel::getShadow()
|
|||
const QRect oldVisibleRect = visibleRect();
|
||||
if (hasShadow()) {
|
||||
dirtyRect = shadow()->shadowRegion().boundingRect();
|
||||
effectWindow()->sceneWindow()->shadow()->updateShadow();
|
||||
if (!effectWindow()->sceneWindow()->shadow()->updateShadow()) {
|
||||
effectWindow()->sceneWindow()->updateShadow(nullptr);
|
||||
}
|
||||
emit shadowChanged();
|
||||
} else {
|
||||
Shadow::createShadow(this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue