forked from osmocom/wireshark
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>
This commit is contained in:
parent
3c9f440ac6
commit
867e6f0e00
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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_;
|
||||
}
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -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_) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue