View Issue Details

IDProjectCategoryView StatusLast Update
0002787ScribusInternalpublic2005-11-05 12:44
Reportercbradney Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAthlon XP 2600+ 1gb ramOSGentoo LinuxOS VersionUp to date
Product Version1.3.1cvs 
Fixed in Version1.3.2cvs 
Summary0002787: Memory leak in colour pixmap caches
DescriptionFixes, recording for posterity's sake.
TagsNo tags attached.
Patch

Activities

2005-11-02 23:24

 

scribus-bug-2787-memory-leak-fix.patch (1,149 bytes)   
--- util.cpp	2005-09-17 05:55:05.000000000 +0200
+++ utilmemleakfixed.cpp	2005-11-03 00:22:32.000000000 +0100
@@ -1201,20 +1201,20 @@
 {
 	static QMap<QRgb, QPixmap*> pxCache;
 
-	QPixmap * pm = pxCache[rgb.rgb()];
-	if (!pm)
-	{
-		pm = new QPixmap(15, 15);
-		pm->fill(rgb);
-		QPainter p;
-		p.begin(pm);
-		p.setBrush(Qt::NoBrush);
-		QPen b(Qt::black, 1);
-		p.setPen(b);
-		p.drawRect(0, 0, 15, 15);
-		p.end();
-		pxCache[rgb.rgb()] = pm;
-	}
+	QRgb index=rgb.rgb();
+	if (pxCache.contains(index))
+		return pxCache[index];
+
+	QPixmap *pm = new QPixmap(15, 15);
+	pm->fill(rgb);
+	QPainter p;
+	p.begin(pm);
+	p.setBrush(Qt::NoBrush);
+	QPen b(Qt::black, 1);
+	p.setPen(b);
+	p.drawRect(0, 0, 15, 15);
+	p.end();
+	pxCache.insert(index, pm);
 	return pm;
 }
 
@@ -1222,12 +1222,13 @@
 {
 	static QMap<QRgb, QPixmap*> pxCache;
 
-	QPixmap * pm = pxCache[rgb.rgb()];
-	if (!pm) {
-		pm = new QPixmap(30, 15);
-		pm->fill(rgb);
-		pxCache[rgb.rgb()] = pm;
-	}
+	QRgb index=rgb.rgb();
+	if (pxCache.contains(index))
+		return pxCache[index];
+
+	QPixmap *pm = new QPixmap(30, 15);
+	pm->fill(rgb);
+	pxCache.insert(index, pm);
 	return pm;
 }
 

cbradney

2005-11-02 23:25

administrator   ~0007313

http://bugs.gentoo.org/show_bug.cgi?id=111300 also.

Issue History

Date Modified Username Field Change
2005-11-02 22:48 cbradney New Issue
2005-11-02 23:05 cbradney File Added: scribus-bug-2787-memory-leak-fix.patch
2005-11-02 23:24 cbradney File Deleted: scribus-bug-2787-memory-leak-fix.patch
2005-11-02 23:24 cbradney File Added: scribus-bug-2787-memory-leak-fix.patch
2005-11-02 23:25 cbradney Status assigned => resolved
2005-11-02 23:25 cbradney Fixed in Version => 1.3.2cvs
2005-11-02 23:25 cbradney Resolution open => fixed
2005-11-02 23:25 cbradney Note Added: 0007313
2005-11-05 12:44 cbradney Status resolved => closed