aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-09-17 23:48:12 +0200
committerAnders Broman <a.broman58@gmail.com>2017-09-20 05:48:06 +0000
commita17bbc184170cf2faf4752f63f4dce0bba9e0dd5 (patch)
treec7767db8e7e7dff8378a4527c98cad97541ba70e /ui
parent3ce30eb1fd395251696c4cbf42b52cfd5b150404 (diff)
qt: Fix some leaked menu objects
Calling QPushButton.setMenu and QMenu.addMenu does not transfer ownership of the menu. Fix some leaks by letting "receiving" object act parent for the menu object. Bug: 14071 Change-Id: Id4edaf895503ef5dd4597eac99c2cdd6ad09b2ff Reviewed-on: https://code.wireshark.org/review/23600 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/expert_info_dialog.cpp2
-rw-r--r--ui/qt/packet_list.cpp10
-rw-r--r--ui/qt/proto_tree.cpp8
-rw-r--r--ui/qt/protocol_hierarchy_dialog.cpp2
-rw-r--r--ui/qt/resolved_addresses_dialog.cpp2
-rw-r--r--ui/qt/rtp_stream_dialog.cpp2
-rw-r--r--ui/qt/traffic_table_dialog.cpp5
-rw-r--r--ui/qt/voip_calls_dialog.cpp2
-rw-r--r--ui/qt/widgets/display_filter_edit.cpp2
9 files changed, 18 insertions, 17 deletions
diff --git a/ui/qt/expert_info_dialog.cpp b/ui/qt/expert_info_dialog.cpp
index 5d95840fc8..b099e561de 100644
--- a/ui/qt/expert_info_dialog.cpp
+++ b/ui/qt/expert_info_dialog.cpp
@@ -213,7 +213,7 @@ ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) :
<< ui->actionShowNote << ui->actionShowChat
<< ui->actionShowComment;
QList<int> severities = QList<int>() << PI_ERROR << PI_WARN << PI_NOTE << PI_CHAT << PI_COMMENT;
- QMenu *severity_menu = new QMenu();
+ QMenu *severity_menu = new QMenu(ui->severitiesPushButton);
// It might be nice to color each menu item to match each severity. It
// might also be nice if Qt supported that...
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index a05fe67b18..f3a60a40d4 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -281,7 +281,7 @@ PacketList::PacketList(QWidget *parent) :
ctx_menu_.addSeparator();
main_menu_item = window()->findChild<QMenu *>("menuApplyAsFilter");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected"));
@@ -291,7 +291,7 @@ PacketList::PacketList(QWidget *parent) :
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected"));
main_menu_item = window()->findChild<QMenu *>("menuPrepareAFilter");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected"));
@@ -313,14 +313,14 @@ PacketList::PacketList(QWidget *parent) :
ctx_menu_.addMenu(&colorize_menu_);
main_menu_item = window()->findChild<QMenu *>("menuSCTP");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionSCTPAnalyseThisAssociation"));
submenu->addAction(window()->findChild<QAction *>("actionSCTPShowAllAssociations"));
submenu->addAction(window()->findChild<QAction *>("actionSCTPFilterThisAssociation"));
main_menu_item = window()->findChild<QMenu *>("menuFollow");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream"));
@@ -330,7 +330,7 @@ PacketList::PacketList(QWidget *parent) :
ctx_menu_.addSeparator();
main_menu_item = window()->findChild<QMenu *>("menuEditCopy");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
action = submenu->addAction(tr("Summary as Text"));
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index f30d1e83dd..32c104a724 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -180,7 +180,7 @@ ProtoTree::ProtoTree(QWidget *parent) :
ctx_menu_.addSeparator();
main_menu_item = window()->findChild<QMenu *>("menuApplyAsFilter");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected"));
@@ -190,7 +190,7 @@ ProtoTree::ProtoTree(QWidget *parent) :
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected"));
main_menu_item = window()->findChild<QMenu *>("menuPrepareAFilter");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected"));
@@ -207,7 +207,7 @@ ProtoTree::ProtoTree(QWidget *parent) :
ctx_menu_.addMenu(&colorize_menu_);
main_menu_item = window()->findChild<QMenu *>("menuFollow");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream"));
submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream"));
@@ -216,7 +216,7 @@ ProtoTree::ProtoTree(QWidget *parent) :
ctx_menu_.addSeparator();
main_menu_item = window()->findChild<QMenu *>("menuEditCopy");
- submenu = new QMenu(main_menu_item->title());
+ submenu = new QMenu(main_menu_item->title(), &ctx_menu_);
ctx_menu_.addMenu(submenu);
submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleItems"));
submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleSelectedTreeItems"));
diff --git a/ui/qt/protocol_hierarchy_dialog.cpp b/ui/qt/protocol_hierarchy_dialog.cpp
index 0db3b6f800..0e235b1196 100644
--- a/ui/qt/protocol_hierarchy_dialog.cpp
+++ b/ui/qt/protocol_hierarchy_dialog.cpp
@@ -231,7 +231,7 @@ ProtocolHierarchyDialog::ProtocolHierarchyDialog(QWidget &parent, CaptureFile &c
copy_button_ = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ApplyRole);
- QMenu *copy_menu = new QMenu();
+ QMenu *copy_menu = new QMenu(copy_button_);
QAction *ca;
ca = copy_menu->addAction(tr("as CSV"));
ca->setToolTip(ui->actionCopyAsCsv->toolTip());
diff --git a/ui/qt/resolved_addresses_dialog.cpp b/ui/qt/resolved_addresses_dialog.cpp
index f8488bdce5..898bdcc7de 100644
--- a/ui/qt/resolved_addresses_dialog.cpp
+++ b/ui/qt/resolved_addresses_dialog.cpp
@@ -281,7 +281,7 @@ void ResolvedAddressesDialog::fillShowMenu()
show_bt->setText(tr("Show"));
if (!show_bt->menu()) {
- show_bt->setMenu(new QMenu());
+ show_bt->setMenu(new QMenu(show_bt));
}
QMenu *show_menu = show_bt->menu();
diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp
index ca6afaccbc..2ec5f3bb15 100644
--- a/ui/qt/rtp_stream_dialog.cpp
+++ b/ui/qt/rtp_stream_dialog.cpp
@@ -252,7 +252,7 @@ RtpStreamDialog::RtpStreamDialog(QWidget &parent, CaptureFile &cf) :
analyze_button_ = ui->buttonBox->addButton(ui->actionAnalyze->text(), QDialogButtonBox::ApplyRole);
analyze_button_->setToolTip(ui->actionAnalyze->toolTip());
- QMenu *copy_menu = new QMenu();
+ QMenu *copy_menu = new QMenu(copy_button_);
QAction *ca;
ca = copy_menu->addAction(tr("as CSV"));
ca->setToolTip(ui->actionCopyAsCsv->toolTip());
diff --git a/ui/qt/traffic_table_dialog.cpp b/ui/qt/traffic_table_dialog.cpp
index 9e371a9ddf..3b836250b1 100644
--- a/ui/qt/traffic_table_dialog.cpp
+++ b/ui/qt/traffic_table_dialog.cpp
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "log.h"
#include "traffic_table_dialog.h"
#include <ui_traffic_table_dialog.h>
@@ -66,9 +67,9 @@ TrafficTableDialog::TrafficTableDialog(QWidget &parent, CaptureFile &cf, const c
ui->absoluteTimeCheckBox->hide();
setWindowSubtitle(QString("%1s").arg(table_name));
- QMenu *copy_menu = new QMenu();
- QAction *ca;
copy_bt_ = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
+ QMenu *copy_menu = new QMenu(copy_bt_);
+ QAction *ca;
ca = copy_menu->addAction(tr("as CSV"));
ca->setToolTip(tr("Copy all values of this page to the clipboard in CSV (Comma Separated Values) format."));
connect(ca, SIGNAL(triggered()), this, SLOT(copyAsCsv()));
diff --git a/ui/qt/voip_calls_dialog.cpp b/ui/qt/voip_calls_dialog.cpp
index 2016c01eaa..9cf547f2cb 100644
--- a/ui/qt/voip_calls_dialog.cpp
+++ b/ui/qt/voip_calls_dialog.cpp
@@ -85,7 +85,7 @@ VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flow
player_button_ = RtpPlayerDialog::addPlayerButton(ui->buttonBox);
copy_button_ = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ApplyRole);
- QMenu *copy_menu = new QMenu();
+ QMenu *copy_menu = new QMenu(copy_button_);
QAction *ca;
ca = copy_menu->addAction(tr("as CSV"));
ca->setToolTip(ui->actionCopyAsCsv->toolTip());
diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp
index 22033087b0..47abe3fefe 100644
--- a/ui/qt/widgets/display_filter_edit.cpp
+++ b/ui/qt/widgets/display_filter_edit.cpp
@@ -88,7 +88,7 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type
if (type_ == DisplayFilterToApply) {
bookmark_button_ = new StockIconToolButton(this, "x-display-filter-bookmark");
bookmark_button_->setCursor(Qt::ArrowCursor);
- bookmark_button_->setMenu(new QMenu());
+ bookmark_button_->setMenu(new QMenu(bookmark_button_));
bookmark_button_->setPopupMode(QToolButton::InstantPopup);
bookmark_button_->setToolTip(tr("Manage saved bookmarks."));
bookmark_button_->setIconSize(QSize(14, 14));