aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-09-26 13:14:02 +0200
committerAnders Broman <a.broman58@gmail.com>2017-10-05 04:21:22 +0000
commit867e6f0e006ae633ab7928a20919e0011bc0c63f (patch)
treee84e5a3ba224022aa03c35c5b041fd535126c646
parent3c9f440ac60ba83f155a89a851f9a1d3cc947f8d (diff)
qt: Fix leaked dialogs
Some dialogs are allocated on heap but not freed when the dialog boxes are closed. This means one dialog instance is leaked each time opened/closed. Also dialogs being subclasses of GeometryStateDialog means they might lack a parent reference and are not automatically freed on application shutdown either. Fix these leaks by letting the dialogs automatically destroy themselves on close (via WA_DeleteOnClose). Capture filter, display filter and capture interfaces dialogs are also leaked on application shutdown. These dialogs are protected by a NULL check that at least prevent multiple instances. Though none of them are freed on application shutdown. Fix leaks by freeing when main window is destroyed. Bug: 14071 Change-Id: I8c5c5a75ad3c89abb5996941875ba5d616a22d9c Reviewed-on: https://code.wireshark.org/review/23747 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/conversation_hash_tables_dialog.cpp2
-rw-r--r--ui/qt/display_filter_expression_dialog.cpp1
-rw-r--r--ui/qt/dissector_tables_dialog.cpp2
-rw-r--r--ui/qt/main_window.cpp15
-rw-r--r--ui/qt/main_window.h3
-rw-r--r--ui/qt/main_window_slots.cpp2
-rw-r--r--ui/qt/manage_interfaces_dialog.cpp1
-rw-r--r--ui/qt/supported_protocols_dialog.cpp1
8 files changed, 20 insertions, 7 deletions
diff --git a/ui/qt/conversation_hash_tables_dialog.cpp b/ui/qt/conversation_hash_tables_dialog.cpp
index 86cb890..11b6cbb 100644
--- a/ui/qt/conversation_hash_tables_dialog.cpp
+++ b/ui/qt/conversation_hash_tables_dialog.cpp
@@ -38,7 +38,7 @@ ConversationHashTablesDialog::ConversationHashTablesDialog(QWidget *parent) :
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4);
-
+ setAttribute(Qt::WA_DeleteOnClose, true);
setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables")));
QString html;
diff --git a/ui/qt/display_filter_expression_dialog.cpp b/ui/qt/display_filter_expression_dialog.cpp
index c63aba0..cb0d75b 100644
--- a/ui/qt/display_filter_expression_dialog.cpp
+++ b/ui/qt/display_filter_expression_dialog.cpp
@@ -71,6 +71,7 @@ DisplayFilterExpressionDialog::DisplayFilterExpressionDialog(QWidget *parent) :
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 2 / 3, parent->height());
+ setAttribute(Qt::WA_DeleteOnClose, true);
setWindowTitle(wsApp->windowTitleString(tr("Display Filter Expression")));
setWindowIcon(wsApp->normalIcon());
diff --git a/ui/qt/dissector_tables_dialog.cpp b/ui/qt/dissector_tables_dialog.cpp
index 07483bb..7a1490b 100644
--- a/ui/qt/dissector_tables_dialog.cpp
+++ b/ui/qt/dissector_tables_dialog.cpp
@@ -83,7 +83,7 @@ DissectorTablesDialog::DissectorTablesDialog(QWidget *parent) :
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4);
-
+ setAttribute(Qt::WA_DeleteOnClose, true);
setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables")));
on_tableTreeWidget_itemSelectionChanged();
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index eeab9fa..380ef7e 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -66,6 +66,7 @@ DIAG_ON(frame-larger-than=)
#include <ui/qt/widgets/display_filter_edit.h>
#include "export_dissection_dialog.h"
#include "file_set_dialog.h"
+#include "filter_dialog.h"
#include "funnel_statistics.h"
#include "import_text_dialog.h"
#include "interface_toolbar.h"
@@ -271,6 +272,8 @@ MainWindow::MainWindow(QWidget *parent) :
, capture_interfaces_dialog_(NULL)
, info_data_()
#endif
+ , display_filter_dlg_(NULL)
+ , capture_filter_dlg_(NULL)
#ifdef _WIN32
, pipe_timer_(NULL)
#else
@@ -739,12 +742,18 @@ MainWindow::~MainWindow()
disconnect(main_ui_->mainStack, 0, 0, 0);
#ifndef Q_OS_MAC
- // file_set_dialog_ is a subclass of GeometryStateDialog.
+ // Below dialogs inherit GeometryStateDialog
// For reasons described in geometry_state_dialog.h no parent is set when
- // instantiating the dialog and as a result the object is not automatically
- // freed by its parent. Free it here explicitly to avoid leak and numerous
+ // instantiating the dialogs and as a resul objects are not automatically
+ // freed by its parent. Free then here explicitly to avoid leak and numerous
// Valgrind complaints.
delete file_set_dialog_;
+ delete capture_filter_dlg_;
+ delete display_filter_dlg_;
+#ifdef HAVE_LIBPCAP
+ delete capture_interfaces_dialog_;
+#endif
+
#endif
delete main_ui_;
}
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 9eeacd0..2208be7 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -63,6 +63,7 @@ class AccordionFrame;
class ByteViewTab;
class CaptureInterfacesDialog;
class FileSetDialog;
+class FilterDialog;
class FunnelStatistics;
class MainWelcome;
class PacketList;
@@ -179,6 +180,8 @@ private:
CaptureInterfacesDialog *capture_interfaces_dialog_;
info_data_t info_data_;
#endif
+ FilterDialog *display_filter_dlg_;
+ FilterDialog *capture_filter_dlg_;
// Pipe input
gint pipe_source_;
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 59e6d2e..ff0c3e4 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -2728,7 +2728,6 @@ void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::Act
emit filterAction(field_filter, action, filter_type);
}
-static FilterDialog *display_filter_dlg_ = NULL;
void MainWindow::on_actionAnalyzeDisplayFilters_triggered()
{
if (!display_filter_dlg_) {
@@ -3736,7 +3735,6 @@ void MainWindow::on_actionCaptureRestart_triggered()
startCapture();
}
-static FilterDialog *capture_filter_dlg_ = NULL;
void MainWindow::on_actionCaptureCaptureFilters_triggered()
{
if (!capture_filter_dlg_) {
diff --git a/ui/qt/manage_interfaces_dialog.cpp b/ui/qt/manage_interfaces_dialog.cpp
index 55948bf..b124f46 100644
--- a/ui/qt/manage_interfaces_dialog.cpp
+++ b/ui/qt/manage_interfaces_dialog.cpp
@@ -87,6 +87,7 @@ ManageInterfacesDialog::ManageInterfacesDialog(QWidget *parent) :
{
ui->setupUi(this);
loadGeometry();
+ setAttribute(Qt::WA_DeleteOnClose, true);
#ifdef Q_OS_MAC
ui->addPipe->setAttribute(Qt::WA_MacSmallSize, true);
diff --git a/ui/qt/supported_protocols_dialog.cpp b/ui/qt/supported_protocols_dialog.cpp
index 0d9c582..a49a89c 100644
--- a/ui/qt/supported_protocols_dialog.cpp
+++ b/ui/qt/supported_protocols_dialog.cpp
@@ -53,6 +53,7 @@ SupportedProtocolsDialog::SupportedProtocolsDialog(QWidget *parent) :
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height());
+ setAttribute(Qt::WA_DeleteOnClose, true);
setWindowTitle(wsApp->windowTitleString(tr("Supported Protocols")));
// Some of our names are unreasonably long.