Commit 96de93b1 authored by Laurent Montel's avatar Laurent Montel 😁

Fix mem leak found by valgrind

--- ktron.cpp   2002/02/27 17:05:26     1.31
+++ ktron.cpp   2002/03/17 17:42:32
@@ -40,17 +40,15 @@
 #include <kstdgameaction.h>
 #include <kapplication.h>
 #include <kstatusbar.h>
-
+#include <kdebug.h>
 #define ID_STATUS_BASE 40

 #define MESSAGE_TIME 2000
-
 KTron::KTron(const char *name)
       : KMainWindow(0, name),
        skillAction(3)
 {
    playerPoints[0]=playerPoints[1]=0;
-
    optionsDialog=0;

    tron=new Tron(this);
@@ -261,7 +259,8 @@ KTron::KTron(const char *name)

 KTron::~KTron()
 {
-       saveSettings();
+   saveSettings();
+   delete tron;
 }


@@ -453,6 +452,7 @@ void KTron::quit()
 {
    saveSettings();
    kapp->quit();
+   delete this;
 }

 void KTron::toggleComPl1()
Index: tron.cpp
===================================================================
RCS file: /home/kde/kdegames/ktron/tron.cpp,v
retrieving revision 1.14
diff -u -u -p -r1.14 tron.cpp
--- tron.cpp    2002/02/27 17:05:26     1.14
+++ tron.cpp    2002/03/17 17:42:32
@@ -75,6 +75,8 @@ Tron::~Tron()
     }
   if(pixmap)
     delete pixmap;
+  delete timer;
+
 }

I don't know why when we call Quit() object is not
destroy. => I must add a "delete this;"
Simon or David is it good ?
If it's good there is a lot of programm which doen't
destroy its object.
I think that quit destroy obj.

svn path=/trunk/kdegames/ktron/; revision=143438
parent 11791d73
......@@ -40,17 +40,15 @@
#include <kstdgameaction.h>
#include <kapplication.h>
#include <kstatusbar.h>
#include <kdebug.h>
#define ID_STATUS_BASE 40
#define MESSAGE_TIME 2000
KTron::KTron(const char *name)
: KMainWindow(0, name),
skillAction(3)
{
playerPoints[0]=playerPoints[1]=0;
optionsDialog=0;
tron=new Tron(this);
......@@ -261,7 +259,8 @@ KTron::KTron(const char *name)
KTron::~KTron()
{
saveSettings();
saveSettings();
delete tron;
}
......@@ -453,6 +452,7 @@ void KTron::quit()
{
saveSettings();
kapp->quit();
delete this;
}
void KTron::toggleComPl1()
......
......@@ -75,6 +75,8 @@ Tron::~Tron()
}
if(pixmap)
delete pixmap;
delete timer;
}
void Tron::createNewPlayfield()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment