diff options
author | Mikael Kanstrup <mikael.kanstrup@gmail.com> | 2017-09-25 23:18:31 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-09-25 23:37:56 +0000 |
commit | a8a3903e55af23bdce550a95ffe14a398fd1204c (patch) | |
tree | ba91f9aae0f2970d4834f97dde6d5c558bdea2db | |
parent | e2d43e7d4b352206bac6bdd42f2c8f04d1e126b2 (diff) |
Qt: Free MainWindow at shutdown
MainWindow is allocated on heap on startup but not freed on shutdown.
Free the object at shutdown mainly to silent Valgrind.
When at it also fix two problems with the MainWindow destructor:
- Deleting main_ui_ triggers a currentChanged signal which in turn
calls mainStackChanged that references the freed main_ui_ object.
Prevent use after free error by disconnecting from the signal before
freeing.
- Explicitly free file_set_dialog_ as no rparent perform the cleanup.
Bug: 14071
Change-Id: I9c1fbef04cf68bfffffea57ef298f4896d6583f9
Reviewed-on: https://code.wireshark.org/review/23739
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | ui/qt/main_window.cpp | 10 | ||||
-rw-r--r-- | wireshark-qt.cpp | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 1d1e9eb24b..e7fcc99032 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -736,6 +736,16 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { + disconnect(main_ui_->mainStack, 0, 0, 0); + +#ifndef Q_OS_MAC + // file_set_dialog_ is a subclass of 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 + // Valgrind complaints. + delete file_set_dialog_; +#endif delete main_ui_; } diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 61fac58a59..538994daef 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -939,6 +939,7 @@ int main(int argc, char *qt_argv[]) ret_val = wsApp->exec(); + delete main_w; recent_cleanup(); epan_cleanup(); |