aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-10-01 00:52:48 +0200
committerAnders Broman <a.broman58@gmail.com>2017-10-05 04:21:46 +0000
commit5a99830e211901e498e036b9adb00b0c33c7904d (patch)
treeee4f41c42621e51346506b647df4a60187a1d2be
parent867e6f0e006ae633ab7928a20919e0011bc0c63f (diff)
Qt: Free dynamic menu actions at shutdown
Some menu actions registered at startup are not freed at shutdown making Valgrind complain. Fix by clearing the lists holding them and making sure all actions have a parent to free them. Bug: 14071 Change-Id: I8d99d062d394a7262b0f9b7ddea4ed71049636ac Reviewed-on: https://code.wireshark.org/review/23793 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>
-rw-r--r--ui/qt/funnel_statistics.cpp6
-rw-r--r--ui/qt/tap_parameter_dialog.cpp2
-rw-r--r--ui/qt/wireshark_application.cpp8
-rw-r--r--ui/qt/wireshark_application.h1
4 files changed, 13 insertions, 4 deletions
diff --git a/ui/qt/funnel_statistics.cpp b/ui/qt/funnel_statistics.cpp
index 18b1b52..e8d0191 100644
--- a/ui/qt/funnel_statistics.cpp
+++ b/ui/qt/funnel_statistics.cpp
@@ -69,8 +69,8 @@ static void progress_window_destroy(struct progdlg *progress_dialog);
class FunnelAction : public QAction
{
public:
- FunnelAction(const QString title, funnel_menu_callback callback, gpointer callback_data, gboolean retap) :
- QAction(NULL),
+ FunnelAction(const QString title, funnel_menu_callback callback, gpointer callback_data, gboolean retap, QObject *parent = 0) :
+ QAction(parent),
title_(title),
callback_(callback),
callback_data_(callback_data),
@@ -310,7 +310,7 @@ static void register_menu_cb(const char *name,
gpointer callback_data,
gboolean retap)
{
- FunnelAction *funnel_action = new FunnelAction(name, callback, callback_data, retap);
+ FunnelAction *funnel_action = new FunnelAction(name, callback, callback_data, retap, wsApp);
if (menus_registered) {
wsApp->appendDynamicMenuGroupItem(group, funnel_action);
} else {
diff --git a/ui/qt/tap_parameter_dialog.cpp b/ui/qt/tap_parameter_dialog.cpp
index 1ff231f..a4f7c5d 100644
--- a/ui/qt/tap_parameter_dialog.cpp
+++ b/ui/qt/tap_parameter_dialog.cpp
@@ -129,7 +129,7 @@ void TapParameterDialog::registerDialog(const QString title, const char *cfg_abb
QString cfg_str = cfg_abbr;
cfg_str_to_creator_[cfg_str] = creator;
- QAction *tpd_action = new QAction(title, NULL);
+ QAction *tpd_action = new QAction(title, wsApp);
tpd_action->setObjectName(action_name_);
tpd_action->setData(cfg_str);
wsApp->addDynamicMenuGroupItem(group, tpd_action);
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index feb9572..0c67b8e 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -864,6 +864,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
WiresharkApplication::~WiresharkApplication()
{
+ clearDynamicMenuGroupItems();
free_filter_lists();
}
@@ -970,6 +971,13 @@ void WiresharkApplication::removeDynamicMenuGroupItem(int group, QAction *sg_act
dynamic_menu_groups_[group].removeAll(sg_action);
}
+void WiresharkApplication::clearDynamicMenuGroupItems()
+{
+ foreach (int group, dynamic_menu_groups_.uniqueKeys()) {
+ dynamic_menu_groups_[group].clear();
+ }
+}
+
QList<QAction *> WiresharkApplication::dynamicMenuGroupItems(int group)
{
if (!dynamic_menu_groups_.contains(group)) {
diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h
index 43dc0fc..1754f83 100644
--- a/ui/qt/wireshark_application.h
+++ b/ui/qt/wireshark_application.h
@@ -161,6 +161,7 @@ private:
unsigned int fileVersion(QString file_path);
void checkForDbar();
#endif
+ void clearDynamicMenuGroupItems();
protected:
bool event(QEvent *event);