From f6e6853dc4c876109ca74fbb14e62ab5ee532d89 Mon Sep 17 00:00:00 2001 From: John Thacker Date: Wed, 15 Feb 2023 21:42:30 -0500 Subject: [PATCH] Qt: Plug leaks in Conversations/Endpoints windows Set some models to have the Traffic Tab or Traffic Type List that creates them as parent, so that they will be deleted properly. Setting a model does not cause it to be deleted unless it is parented, because models can be shared among multiple views. Since these models are only used by the one view, parenting them is fine. --- ui/qt/widgets/traffic_tab.cpp | 3 ++- ui/qt/widgets/traffic_types_list.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/qt/widgets/traffic_tab.cpp b/ui/qt/widgets/traffic_tab.cpp index 1fbc850d28..f4dcec0c43 100644 --- a/ui/qt/widgets/traffic_tab.cpp +++ b/ui/qt/widgets/traffic_tab.cpp @@ -123,6 +123,7 @@ QTreeView * TrafficTab::createTree(int protoId) if (_createModel) { ATapDataModel * model = _createModel(protoId, ""); + model->setParent(tree); connect(model, &ATapDataModel::tapListenerChanged, tree, &TrafficTree::tapListenerEnabled); model->enableTap(); @@ -136,7 +137,7 @@ QTreeView * TrafficTab::createTree(int protoId) } } - TrafficDataFilterProxy * proxyModel = new TrafficDataFilterProxy(); + TrafficDataFilterProxy * proxyModel = new TrafficDataFilterProxy(tree); proxyModel->setSourceModel(model); tree->setModel(proxyModel); diff --git a/ui/qt/widgets/traffic_types_list.cpp b/ui/qt/widgets/traffic_types_list.cpp index ac8036abb9..0fe5feba93 100644 --- a/ui/qt/widgets/traffic_types_list.cpp +++ b/ui/qt/widgets/traffic_types_list.cpp @@ -239,9 +239,9 @@ void TrafficTypesList::setProtocolInfo(QString name, GList ** recentList) { _name = name; - _sortModel = new TrafficListSortModel(); + _sortModel = new TrafficListSortModel(this); - _model = new TrafficTypesModel(recentList); + _model = new TrafficTypesModel(recentList, this); _sortModel->setSourceModel(_model); setModel(_sortModel);