fix: remove unexpected and undefined mask behavior

ProxyWindowBase no longer takes ownership of the mask.
It is no longer undefined behavior to set the mask to null.
This commit is contained in:
outfoxxed committed 2024-03-04 17:20:25 -08:00
1 parent e1bb5dfd3b
commit 3d4b8efc74
2 files changed
+14 -3

No files matched your search

+13 -3
View File
@@ -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) {