fixed #1362 rightclick on empty split crash

This commit is contained in:
fourtf 2019-10-12 11:17:40 +02:00
parent 6f710823ed
commit 8153aa7d40
2 changed files with 4 additions and 5 deletions

View file

@ -213,9 +213,7 @@ void SplitHeader::initializeLayout()
this->dropdownButton_ = makeWidget<Button>([&](auto w) { this->dropdownButton_ = makeWidget<Button>([&](auto w) {
/// XXX: this never gets disconnected /// XXX: this never gets disconnected
this->split_->channelChanged.connect([this] { this->split_->channelChanged.connect([this] {
auto menu = this->createMainMenu(); this->dropdownButton_->setMenu(this->createMainMenu());
this->mainMenu_ = menu.get();
this->dropdownButton_->setMenu(std::move(menu));
}); });
}), }),
// add split // add split
@ -598,7 +596,9 @@ void SplitHeader::mousePressEvent(QMouseEvent *event)
break; break;
case Qt::RightButton: { case Qt::RightButton: {
this->mainMenu_->popup(this->mapToGlobal(event->pos())); auto menu = this->createMainMenu().release();
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->popup(this->mapToGlobal(event->pos() + QPoint(0, 4)));
} }
break; break;
} }

View file

@ -55,7 +55,6 @@ private:
// ui // ui
Button *dropdownButton_{}; Button *dropdownButton_{};
QMenu *mainMenu_{};
Label *titleLabel_{}; Label *titleLabel_{};
EffectLabel *modeButton_{}; EffectLabel *modeButton_{};
Button *moderationButton_{}; Button *moderationButton_{};