summaryrefslogtreecommitdiff
path: root/ui/qt/sparkline_delegate.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-01-11 00:33:46 +0100
committerRoland Knall <rknall@gmail.com>2017-01-12 13:41:09 +0000
commitf8dc2346dfa5df67749583a428f9a76b2f61acb1 (patch)
tree441a4d5565bb46e01cca7e83cf5fe183830d5a8b /ui/qt/sparkline_delegate.cpp
parent4b3b3f587726bf055c252b4497d10375c08b5993 (diff)
downloadwireshark-f8dc2346dfa5df67749583a428f9a76b2f61acb1.tar.gz
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/sparkline_delegate.cpp')
-rw-r--r--ui/qt/sparkline_delegate.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/ui/qt/sparkline_delegate.cpp b/ui/qt/sparkline_delegate.cpp
index b4e565cc0d..b9935d94e8 100644
--- a/ui/qt/sparkline_delegate.cpp
+++ b/ui/qt/sparkline_delegate.cpp
@@ -29,7 +29,7 @@
void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
- QList<int> *points = qvariant_cast<QList<int> *>(index.data(Qt::UserRole));
+ QList<int> points = qvariant_cast<QList<int> >(index.data(Qt::UserRole));
int max = 1;
int em_w = option.fontMetrics.height();
int content_w = option.rect.width() - (em_w / 4);
@@ -42,19 +42,19 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
QStyledItemDelegate::paint(painter, option, index);
- if (!points || points->isEmpty() || steps < 1.0 || content_h <= 0) {
+ if (points.isEmpty() || steps < 1.0 || content_h <= 0) {
return;
}
- while((qreal) points->length() > steps) {
- points->removeFirst();
+ while((qreal) points.length() > steps) {
+ points.removeFirst();
}
- foreach (val, *points) {
+ foreach (val, points) {
if (val > max) max = val;
}
- foreach (val, *points) {
+ foreach (val, points) {
fpoints.append(QPointF(idx, (qreal) content_h - (val * content_h / max)));
idx = idx + step_w;
}