WlanStatisticsDialog: fix memory leaks

Remember the delegates that we use and free them explicitly
in the destructor.

Change-Id: I79698eb6ee4f565efcb3f02ac6239914c6acf3f5
Reviewed-on: https://code.wireshark.org/review/36964
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Martin Kaiser 2020-04-27 22:36:07 +02:00 committed by Anders Broman
parent b7ea495e2e
commit 8025250313
2 changed files with 8 additions and 2 deletions

View File

@ -501,8 +501,10 @@ WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, con
<< tr("Deauths") << tr("Other");
statsTreeWidget()->setHeaderLabels(header_labels);
updateHeaderLabels();
statsTreeWidget()->setItemDelegateForColumn(col_pct_packets_, new PercentBarDelegate());
statsTreeWidget()->setItemDelegateForColumn(col_pct_retry_, new PercentBarDelegate());
packets_delegate_ = new PercentBarDelegate();
statsTreeWidget()->setItemDelegateForColumn(col_pct_packets_, packets_delegate_);
retry_delegate_ = new PercentBarDelegate();
statsTreeWidget()->setItemDelegateForColumn(col_pct_retry_, retry_delegate_);
statsTreeWidget()->sortByColumn(col_bssid_, Qt::AscendingOrder);
// resizeColumnToContents doesn't work well here, so set sizes manually.
@ -546,6 +548,8 @@ WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, con
WlanStatisticsDialog::~WlanStatisticsDialog()
{
delete packets_delegate_;
delete retry_delegate_;
delete add_station_timer_;
}

View File

@ -11,6 +11,7 @@
#define WLANSTATISTICSDIALOG_H
#include "tap_parameter_dialog.h"
#include <ui/qt/models/percent_bar_delegate.h>
class QElapsedTimer;
@ -27,6 +28,7 @@ protected:
private:
int packet_count_;
int cur_network_;
PercentBarDelegate *packets_delegate_, *retry_delegate_;
QElapsedTimer *add_station_timer_;
QString displayFilter_;