Removed destructor from Platform since EmuFrontFileObject destructor
authorMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 24 Nov 2010 21:32:54 +0000 (23:32 +0200)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 24 Nov 2010 21:32:54 +0000 (23:32 +0200)
does the destructing job properly already.

src/dataobjects/emufrontfileobject.cpp
src/dataobjects/platform.cpp
src/dataobjects/platform.h
testing/EmuFrontTesting/platformtest.cpp
testing/EmuFrontTesting/platformtest.h

index c60c895..7928aac 100644 (file)
@@ -18,6 +18,7 @@
 // along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "emufrontfileobject.h"
+#include <QDebug>
 
 EmuFrontFileObject::EmuFrontFileObject()
     : EmuFrontObject(-1, ""), file(0) { }
@@ -34,7 +35,9 @@ EmuFrontFileObject::EmuFrontFileObject(const EmuFrontFileObject &pl)
 
 EmuFrontFileObject::~EmuFrontFileObject()
 {
-    if (file) delete file;
+    qDebug() << "EmuFrontFileObject " << name << " dying";
+    if (file) qDebug() << "File " << file->getName() << " will also be deleted.";
+    delete file;
 }
 
 EmuFrontFileObject& EmuFrontFileObject::operator =(const EmuFrontFileObject &ob)
@@ -42,7 +45,7 @@ EmuFrontFileObject& EmuFrontFileObject::operator =(const EmuFrontFileObject &ob)
     if (this == &ob) return (*this);
     id = ob.id;
     name = ob.name;
-    if (file) delete file;
+    delete file;
     EmuFrontFile *f = ob.file;
     file = new EmuFrontFile(*f);
     return (*this);
index 490a349..e0082d0 100644 (file)
@@ -34,13 +34,3 @@ Platform::Platform(const Platform &p)
         : EmuFrontFileObject(p)
 {
 }
-
-Platform::~Platform()
-{
-    if (file) {
-        qDebug() << "file: " << file->getName();
-    }
-    qDebug() << "Platform " << name << " @ "
-        << this << "dying.";
-}
-
index 186946a..994e9b4 100644 (file)
@@ -29,7 +29,6 @@ public:
     Platform(int id, QString name);
     Platform(int id, QString name, EmuFrontFile*);
     Platform(const Platform &);
-    ~Platform();
 };
 
 #endif // PLATFORM_H
index 2a4d932..88324ad 100644 (file)
@@ -82,7 +82,7 @@ void PlatformTest::equals2()
     // and pointer from p6 would keep pointing to memory area where
     // efA no longer exists:
     //Platform p6(1, "test", efA);
-    Platform p6(1, "test", efA);
+    Platform p6(1, "test", efB);
 
     qDebug() << "efA" << efA->getName();
     qDebug() << "efB" << efB->getName();
index ed57e9c..1be331b 100644 (file)
@@ -25,8 +25,7 @@ private slots:
 private:
     //EmuFrontFile *ef;
 /*
-    EmuFrontFile *efile;
-    */
+    EmuFrontFile *efile;*/
     //EmuFrontFile *efA;
     //EmuFrontFile *efB;