[Kwintv] Patch to fix memory leak when lirc-support is in

Morten Brix Pedersen kwintv@mail.kde.org
Tue, 15 Oct 2002 12:42:48 +0200


--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

This patch fixes a small memory leak when Lirc support is compiled in.

  - Morten.


--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kwintv3_leak.diff"

? kwintv3_leak.diff
? qtvision/.lirc.cpp.swp
? qtvision/.lirc.h.swp
? qtvision/.qtvision.cpp.swp
? qtvision/.qtvision.h.swp
? qtvision/clients/.actions.cpp.swp
? qtvision/clients/.actions.h.swp
? qtvision/clients/.mainwindow.cpp.swp
? qtvision/clients/.mainwindow.h.swp
? qtvision/clients/.sidebar.h.swp
? qtvision/teletext/Makefile
Index: qtvision/clients/mainwindow.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/clients/mainwindow.cpp,v
retrieving revision 1.48
diff -u -r1.48 mainwindow.cpp
--- qtvision/clients/mainwindow.cpp	4 Oct 2002 23:53:35 -0000	1.48
+++ qtvision/clients/mainwindow.cpp	15 Oct 2002 10:44:25 -0000
@@ -75,10 +75,6 @@
 # include <config.h>
 #endif
 
-#ifdef HAVE_LIRC
-#include "lirc.h"
-#endif // HAVE_LIRC
-
 #include "mainwindow.h"
 #include "mainwindow.moc"
 
@@ -183,6 +179,10 @@
     saveWindowSize( config );
     config->sync();
     
+#ifdef HAVE_LIRC
+    delete lirc;
+#endif
+
     // So we don't crash on exit
     delete actions;
 }
@@ -237,7 +237,7 @@
 void MainWindow::setupInfraRed()
 {
 #ifdef HAVE_LIRC
-    Lirc* lirc = new Lirc(parent(), "qtvision");
+    lirc = new Lirc(parent(), "qtvision");
     QMap<QString, QString>* lircKeyMap = new QMap<QString, QString>();
     (*lircKeyMap)["CH+"] = "channel_up";
     (*lircKeyMap)["CH-"] = "channel_down";
Index: qtvision/clients/mainwindow.h
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/clients/mainwindow.h,v
retrieving revision 1.24
diff -u -r1.24 mainwindow.h
--- qtvision/clients/mainwindow.h	4 Oct 2002 02:41:00 -0000	1.24
+++ qtvision/clients/mainwindow.h	15 Oct 2002 10:44:25 -0000
@@ -24,6 +24,10 @@
 
 #include <kmainwindow.h>
 
+#ifdef HAVE_LIRC
+#include "lirc.h"
+#endif // HAVE_LIRC
+
 class QSplitter;
 class QVBox;
 
@@ -101,6 +105,10 @@
     ToggleViewAction *actShowSidebar;
     ToggleViewAction *actShowViewbar;
     ToggleViewAction *actShowVolbar;
+
+#ifdef HAVE_LIRC
+    Lirc *lirc;
+#endif
 
     bool screenSaverWasEnabled;
     bool dpmsWasEnabled;

--OgqxwSJOaUobr8KG--