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 2024-03-04 17:20:25 -08:00
parent e1bb5dfd3b
commit 3d4b8efc74
Signed by untrusted user: outfoxxed
GPG Key ID: 4C88A185FB89301E
2 changed files with 14 additions and 3 deletions

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) {

View File

@ -97,6 +97,7 @@ protected slots:
virtual void onWidthChanged();
virtual void onHeightChanged();
void onMaskChanged();
void onMaskDestroyed();
void onScreenDestroyed();
protected: