core/menu: correctly handle menu destruction while open

This commit is contained in:
outfoxxed 2024-12-05 19:46:08 -08:00
parent 26280b34b4
commit 2d05c7a89e
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -78,8 +78,17 @@ void QsMenuAnchor::onClosed() {
this->platformMenu = nullptr;
}
QObject::disconnect(this->mMenu, &QsMenuHandle::menuChanged, this, &QsMenuAnchor::onMenuChanged);
this->mMenu->unrefHandle();
if (this->mMenu) {
QObject::disconnect(
this->mMenu,
&QsMenuHandle::menuChanged,
this,
&QsMenuAnchor::onMenuChanged
);
this->mMenu->unrefHandle();
}
emit this->closed();
emit this->visibleChanged();
}
@ -109,6 +118,7 @@ bool QsMenuAnchor::isVisible() const { return this->mOpen; }
void QsMenuAnchor::onMenuDestroyed() {
this->mMenu = nullptr;
this->onClosed();
emit this->menuChanged();
}