Skip to content

Commit

Permalink
cabana: fix QMenu leak (commaai#29956)
Browse files Browse the repository at this point in the history
fix qmenu leak
  • Loading branch information
deanlee authored Sep 18, 2023
1 parent da4d4cf commit a450eff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/cabana/messageswidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void MessageView::updateBytesSectionSize() {
}

void MessageView::headerContextMenuEvent(const QPoint &pos) {
QMenu *menu = new QMenu(this);
QMenu menu(this);
int cur_index = header()->logicalIndexAt(pos);

QAction *action;
Expand All @@ -434,9 +434,9 @@ void MessageView::headerContextMenuEvent(const QPoint &pos) {

// Hide show action
if (header()->isSectionHidden(logical_index)) {
action = menu->addAction(tr("  %1").arg(column_name), [=]() { header()->showSection(logical_index); });
action = menu.addAction(tr("  %1").arg(column_name), [=]() { header()->showSection(logical_index); });
} else {
action = menu->addAction(tr("✓ %1").arg(column_name), [=]() { header()->hideSection(logical_index); });
action = menu.addAction(tr("✓ %1").arg(column_name), [=]() { header()->hideSection(logical_index); });
}

// Can't hide the name column
Expand All @@ -450,7 +450,7 @@ void MessageView::headerContextMenuEvent(const QPoint &pos) {
}
}

menu->popup(header()->mapToGlobal(pos));
menu.exec(header()->mapToGlobal(pos));
}

MessageViewHeader::MessageViewHeader(QWidget *parent) : QHeaderView(Qt::Horizontal, parent) {
Expand Down

0 comments on commit a450eff

Please sign in to comment.