[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: KDE 1.1.2 khtmlw memory leak patch - please test!
From: "Bjarni R. Einarsson" <bre () netverjar ! is>
Date: 1999-08-28 1:54:23
[Download RAW message or body]
Hi!
Regarding http://bugs.kde.org/db/18/1812.html .
I know I said I didn't know squat about Qt programming. Well I
don't. But the lack of responses here on kfm-devel, some browsing
of the khtmlw source code and "man qdict" inspired me to try
anyway.
Attached is an untested patch to fix the X/pixmap/cache memory
leak in kdelibs/khtmlw. Yeah, I said untested. I don't have
enough horsepower on my desk to build the KDE libs here at home,
but I will test it when I get to work on Monday. Just compiling
the khtmlw widget to check for syntax errors was painful enough!
The patch is really small, and I can't imagine why it wouldn't
work. And if it doesn't work, at least it's a start?
According to the release cycle news, this sort of thing WILL be
accepted into the final release if two developers approve it...
If it works, do I get my name in the AUTHORS file? ;-)
(Sorry if this isn't the right list - please forward it somewhere
appropriate if I got this wrong.)
--
Bjarni R. Einarsson PGP: 02764305, B7A3AB89
bre@netverjar.is -><- http://www.mmedia.is/~bre/
["khtmlw.memleak.patch" (text/plain)]
Common subdirectories: khtmlw.org/.libs and khtmlw/.libs
Common subdirectories: khtmlw.org/CVS and khtmlw/CVS
diff -u khtmlw.org/htmlobj.cpp khtmlw/htmlobj.cpp
--- khtmlw.org/htmlobj.cpp Mon Jan 18 10:57:54 1999
+++ khtmlw/htmlobj.cpp Sat Aug 28 01:29:08 1999
@@ -1239,12 +1239,19 @@
//-----------------------------------------------------------------------------
+
HTMLCachedImage::HTMLCachedImage( const char *_filename )
{
pixmap = 0;
filename = _filename;
}
+HTMLCachedImage::~HTMLCachedImage( )
+{
+ if (pixmap) delete pixmap;
+ pixmap = 0;
+}
+
QPixmap* HTMLCachedImage::getPixmap()
{
if ( !pixmap )
@@ -1263,6 +1270,7 @@
if( !pCache )
{
pCache = new QDict<HTMLCachedImage>( 503, true, false );
+ pCache->setAutoDelete(TRUE);
return 0l;
}
@@ -1279,8 +1287,10 @@
{
// Since this method is static, it is possible that pCache has not
// yet been initialized. Better be careful.
- if( !pCache )
+ if( !pCache ) {
pCache = new QDict<HTMLCachedImage>( 503, true, false );
+ pCache->setAutoDelete(TRUE);
+ }
pCache->insert( _filename, new HTMLCachedImage( _filename ) );
}
@@ -1290,8 +1300,10 @@
int _max_width, int _width, int _height, int _percent, int bdr )
: QObject(), HTMLObject()
{
- if ( pCache == 0 )
+ if ( pCache == 0 ) {
pCache = new QDict<HTMLCachedImage>( 503, true, false );;
+ pCache->setAutoDelete(TRUE);
+ }
pixmap = 0;
movieCache = 0;
diff -u khtmlw.org/htmlobj.h khtmlw/htmlobj.h
--- khtmlw.org/htmlobj.h Sun Dec 6 19:55:48 1998
+++ khtmlw/htmlobj.h Sat Aug 28 01:29:08 1999
@@ -571,7 +571,7 @@
{
public:
HTMLCachedImage( const char * );
- virtual ~HTMLCachedImage() { }
+ virtual ~HTMLCachedImage();
QPixmap* getPixmap();
const char *getFileName() { return filename.data(); }
@@ -669,9 +669,9 @@
QString imageURL;
KHTMLWidget *htmlWidget;
-
- static QDict<HTMLCachedImage>* pCache;
+ static QDict<HTMLCachedImage>* pCache;
+
/*
* Flag telling wether this image was found in the cache
* If this flag is set, you may not delete the pixmap since the pixmap
Common subdirectories: khtmlw.org/test and khtmlw/test
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic