Skip to content

Commit

Permalink
core/menu: correctly handle menu destruction while open
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed Dec 6, 2024
1 parent 26280b3 commit 2d05c7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/qsmenuanchor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -109,6 +118,7 @@ bool QsMenuAnchor::isVisible() const { return this->mOpen; }

void QsMenuAnchor::onMenuDestroyed() {
this->mMenu = nullptr;
this->onClosed();
emit this->menuChanged();
}

Expand Down

0 comments on commit 2d05c7a

Please sign in to comment.