diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-01-11 00:33:46 +0100 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-01-12 13:41:09 +0000 |
commit | f8dc2346dfa5df67749583a428f9a76b2f61acb1 (patch) | |
tree | 441a4d5565bb46e01cca7e83cf5fe183830d5a8b /ui/qt/capture_interfaces_dialog.cpp | |
parent | 4b3b3f587726bf055c252b4497d10375c08b5993 (diff) |
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 <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/capture_interfaces_dialog.cpp')
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<int> *points = ti->data(col_traffic_, Qt::UserRole).value<QList<int> *>(); - points->append(device->packet_diff); + QList<int> points = ti->data(col_traffic_, Qt::UserRole).value<QList<int> >(); + 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<int> *points = data(col_traffic_, Qt::UserRole).value<QList<int> *>(); - QList<int> *other_points = other.data(col_traffic_, Qt::UserRole).value<QList<int> *>(); + QList<int> points = data(col_traffic_, Qt::UserRole).value<QList<int> >(); + QList<int> other_points = other.data(col_traffic_, Qt::UserRole).value<QList<int> >(); 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; } |