From f8dc2346dfa5df67749583a428f9a76b2f61acb1 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 11 Jan 2017 00:33:46 +0100 Subject: Qt: fix memleak of PointList in interface statistics The list of points (for interface traffic statistics) is part of the interface tree model/view. Remove the pointer indirection to simplify cleanup and avoid leaking a PointList. Note that the SparkLineDelegate is used in two different places (CaptureInterfacesDialog and InterfaceTreeModel). Change-Id: I5fef7dadd44fdf58c07844fee269f509c712a36f Reviewed-on: https://code.wireshark.org/review/19606 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- ui/qt/capture_interfaces_dialog.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ui/qt/capture_interfaces_dialog.cpp') diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index d5a15777b8..b4fb9e1713 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -648,7 +648,7 @@ void CaptureInterfacesDialog::updateInterfaces() InterfaceTreeWidgetItem *ti = new InterfaceTreeWidgetItem(ui->interfaceTree); ti->setFlags(ti->flags() | Qt::ItemIsEditable); ti->setData(col_interface_, Qt::UserRole, QString(device->name)); - ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(&ti->points)); + ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(ti->points)); ti->setText(col_interface_, device->display_name); if (device->no_addresses > 0) { @@ -766,8 +766,8 @@ void CaptureInterfacesDialog::updateStatistics(void) if (device_name.compare(device->display_name) || device->hidden || device->type == IF_PIPE) { continue; } - QList *points = ti->data(col_traffic_, Qt::UserRole).value *>(); - points->append(device->packet_diff); + QList points = ti->data(col_traffic_, Qt::UserRole).value >(); + points.append(device->packet_diff); ti->setData(col_traffic_, Qt::UserRole, qVariantFromValue(points)); } } @@ -1101,14 +1101,14 @@ interface_t *CaptureInterfacesDialog::getDeviceByName(const QString device_name) // bool InterfaceTreeWidgetItem::operator< (const QTreeWidgetItem &other) const { if (treeWidget()->sortColumn() == col_traffic_) { - QList *points = data(col_traffic_, Qt::UserRole).value *>(); - QList *other_points = other.data(col_traffic_, Qt::UserRole).value *>(); + QList points = data(col_traffic_, Qt::UserRole).value >(); + QList other_points = other.data(col_traffic_, Qt::UserRole).value >(); double avg = 0, other_avg = 0; - foreach (int point, *points) { - avg += (double) point / points->length(); + foreach (int point, points) { + avg += (double) point / points.length(); } - foreach (int point, *other_points) { - other_avg += (double) point / other_points->length(); + foreach (int point, other_points) { + other_avg += (double) point / other_points.length(); } return avg < other_avg; } -- cgit v1.2.3