From kde-core-devel Wed Jun 27 19:52:31 2001 From: Kurt Granroth Date: Wed, 27 Jun 2001 19:52:31 +0000 To: kde-core-devel Subject: [PATCH] Memory leaks in kcontrol/background X-MARC-Message: https://marc.info/?l=kde-core-devel&m=99367547725737 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------Boundary-00=_JVTLP2PRSY5AA0G319HD" --------------Boundary-00=_JVTLP2PRSY5AA0G319HD Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit This patch fixes a memory leak in the background control panel. There are two parts to it. The first replaces a QArray with a QVector. According to the QArray docs, only simple types should be stored in it.. i.e., objects with no virtual functions or destructors. Well, these objects *do* have destructors and they were never called. Using a QVector ensured that they were. The second calls the 'cleanup()' method in the destructor. This is needed to delete all the objects put on the heap.. not just one of them. -- Kurt Granroth | http://www.granroth.org KDE Developer/Evangelist | SuSE Labs Open Source Developer granroth@kde.org | granroth@suse.com KDE -- Conquer Your Desktop --------------Boundary-00=_JVTLP2PRSY5AA0G319HD Content-Type: text/x-diff; charset="iso-8859-1"; name="background.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="background.diff" Index: backgnd.cpp =================================================================== RCS file: /home/kde/kdebase/kcontrol/background/backgnd.cpp,v retrieving revision 1.28 diff -b -u -r1.28 backgnd.cpp --- backgnd.cpp 2001/06/18 05:20:43 1.28 +++ backgnd.cpp 2001/06/27 19:43:15 @@ -110,6 +110,7 @@ m_Max( KWin::numberOfDesktops() ), m_Renderer( m_Max ) { + m_Renderer.setAutoDelete(true); KImageIO::registerFormats(); int screen_number = 0; @@ -358,7 +359,7 @@ m_Desk = KWin::currentDesktop() - 1; m_pGlobals = new KGlobalBackgroundSettings(); for (int i=0; i #include #include +#include #include #include @@ -119,7 +120,7 @@ QSpinBox *m_pCacheBox; QMap m_Wallpaper; - QArray m_Renderer; + QVector m_Renderer; KGlobalBackgroundSettings *m_pGlobals; KColorButton *m_pColor1But, *m_pColor2But; KBGMonitor *m_pMonitor; Index: bgrender.cc =================================================================== RCS file: /home/kde/kdebase/kcontrol/background/bgrender.cc,v retrieving revision 1.11 diff -b -u -r1.11 bgrender.cc --- bgrender.cc 2001/03/26 11:44:57 1.11 +++ bgrender.cc 2001/06/27 19:43:15 @@ -77,7 +77,7 @@ KBackgroundRenderer::~KBackgroundRenderer() { - delete m_pImage; + cleanup(); delete m_Tempfile; } --------------Boundary-00=_JVTLP2PRSY5AA0G319HD--