From 3c3850d6920ef5ab5c266f02b399922ed42eb728 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Fri, 14 Nov 2014 17:52:55 -0200
Subject: [PATCH] Fix memleak on Pixmap cache

as we load dives and dives, new DiveEvents will be created
but the transparent pixmap never deleted, also this makes
the transparent pixmap only for the correct event, not for
all of them.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveeventitem.cpp | 14 +++++++-------
 qt-ui/profile/diveeventitem.h   |  1 -
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 5ceb469..a9c3c3f 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -20,12 +20,6 @@ DiveEventItem::DiveEventItem(QObject *parent) : DivePixmapItem(parent),
 	internalEvent(NULL)
 {
 	setFlag(ItemIgnoresTransformations);
-	// create a narrow but somewhat tall, basically transparent pixmap
-	// that allows tooltips to work when we don't want to show a specific
-	// pixmap for an event, but want to show the event value in the tooltip
-	// (e.g. if there is heading data in every sample)
-	transparentPixmap = new QPixmap(4, 20);
-	transparentPixmap->fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.01));
 }
 
 
@@ -79,7 +73,13 @@ void DiveEventItem::setupPixmap()
 		// some dive computers have heading in every sample...
 		// set an "almost invisible" pixmap
 		// so we get the tooltip but not the clutter
-		setPixmap(*transparentPixmap);
+		// create a narrow but somewhat tall, basically transparent pixmap
+		// that allows tooltips to work when we don't want to show a specific
+		// pixmap for an event, but want to show the event value in the tooltip
+		// (e.g. if there is heading data in every sample)
+		QPixmap transparentPixmap(4, 20);
+		transparentPixmap.fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.01));
+		setPixmap(transparentPixmap);
 	} else if (event_is_gaschange(internalEvent)) {
 		if (internalEvent->gas.mix.he.permille)
 			setPixmap(EVENT_PIXMAP_BIGGER(":gaschangeTrimix"));
diff --git a/qt-ui/profile/diveeventitem.h b/qt-ui/profile/diveeventitem.h
index 2657b3b..f358fee 100644
--- a/qt-ui/profile/diveeventitem.h
+++ b/qt-ui/profile/diveeventitem.h
@@ -29,7 +29,6 @@ private:
 	DiveCartesianAxis *hAxis;
 	DivePlotDataModel *dataModel;
 	struct event *internalEvent;
-	QPixmap *transparentPixmap;
 };
 
 #endif // DIVEEVENTITEM_H
-- 
2.1.3

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to