add parent widget for card menus

This commit is contained in:
mappu 2018-10-02 19:52:00 +13:00
parent 52ab4b1aa3
commit 7fa01775f7
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ TrayIcon::TrayIcon(QObject *parent) :
this->menu = new QMenu(); // can only be explicitly owned by a QWidget, not any QObject, so we need to
// manually manage its lifecycle in the d'tor
this->quitAction = new QAction("Quit");
this->quitAction = new QAction("Quit"); // Don't have these owned by this->menu, otherwise we can't delete + readd them in refresh
this->quitAction->setIcon(QIcon::fromTheme("application-exit"));
connect(this->quitAction, &QAction::triggered, this, &TrayIcon::on_quitAction_triggered);
@ -98,8 +98,8 @@ void TrayIcon::onGotPulseCardInfo(const pa_card_info& cardInfo, int eol)
name = tr("Default card");
}
QMenu* cardMenu = new QMenu(name);
cardMenu->setIcon(QIcon::fromTheme("audio-card"));
QMenu* cardMenu = new QMenu(name, this->menu); // recursive ownership
for (size_t i = 0; i < cardInfo.n_profiles; ++i) {
auto profileAction = new QAction(cardInfo.profiles[i].description, cardMenu);
cardMenu->addAction(profileAction);