Skip to content

Commit 2d05c7a

Browse files
committed
core/menu: correctly handle menu destruction while open
1 parent 26280b3 commit 2d05c7a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/qsmenuanchor.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,17 @@ void QsMenuAnchor::onClosed() {
7878
this->platformMenu = nullptr;
7979
}
8080

81-
QObject::disconnect(this->mMenu, &QsMenuHandle::menuChanged, this, &QsMenuAnchor::onMenuChanged);
82-
this->mMenu->unrefHandle();
81+
if (this->mMenu) {
82+
QObject::disconnect(
83+
this->mMenu,
84+
&QsMenuHandle::menuChanged,
85+
this,
86+
&QsMenuAnchor::onMenuChanged
87+
);
88+
89+
this->mMenu->unrefHandle();
90+
}
91+
8392
emit this->closed();
8493
emit this->visibleChanged();
8594
}
@@ -109,6 +118,7 @@ bool QsMenuAnchor::isVisible() const { return this->mOpen; }
109118

110119
void QsMenuAnchor::onMenuDestroyed() {
111120
this->mMenu = nullptr;
121+
this->onClosed();
112122
emit this->menuChanged();
113123
}
114124

0 commit comments

Comments
 (0)