diff --git a/src/core/proxywindow.cpp b/src/core/proxywindow.cpp index f95b6c3..f825be6 100644 --- a/src/core/proxywindow.cpp +++ b/src/core/proxywindow.cpp @@ -172,22 +172,32 @@ void ProxyWindowBase::setColor(QColor color) { PendingRegion* ProxyWindowBase::mask() const { return this->mMask; } void ProxyWindowBase::setMask(PendingRegion* mask) { + if (mask == this->mMask) return; + if (this->mMask != nullptr) { - this->mMask->deleteLater(); + QObject::disconnect(this->mMask, nullptr, this, nullptr); } + this->mMask = mask; + if (mask != nullptr) { mask->setParent(this); - this->mMask = mask; + QObject::connect(mask, &QObject::destroyed, this, &ProxyWindowBase::onMaskDestroyed); QObject::connect(mask, &PendingRegion::changed, this, &ProxyWindowBase::maskChanged); - emit this->maskChanged(); } + + emit this->maskChanged(); } void ProxyWindowBase::onMaskChanged() { if (this->window != nullptr) this->updateMask(); } +void ProxyWindowBase::onMaskDestroyed() { + this->mMask = nullptr; + emit this->maskChanged(); +} + void ProxyWindowBase::updateMask() { QRegion mask; if (this->mMask != nullptr) { diff --git a/src/core/proxywindow.hpp b/src/core/proxywindow.hpp index 52a839c..accd434 100644 --- a/src/core/proxywindow.hpp +++ b/src/core/proxywindow.hpp @@ -97,6 +97,7 @@ protected slots: virtual void onWidthChanged(); virtual void onHeightChanged(); void onMaskChanged(); + void onMaskDestroyed(); void onScreenDestroyed(); protected: