Executable class member initializations and debugging db error.
authorMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 6 Oct 2010 20:23:55 +0000 (23:23 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 6 Oct 2010 20:23:55 +0000 (23:23 +0300)
src/dataobjects/executable.cpp
src/db/dbexecutable.cpp
src/dialogs/executablemaindialog.cpp

index 2fbb565..c16baef 100644 (file)
@@ -20,7 +20,7 @@
 #include "executable.h"
 #include "setup.h"
 
-Executable::Executable() : EmuFrontObject() { }
+Executable::Executable() : EmuFrontObject(), executable(""), options(""), setup(0), type(-1) { }
 
 Executable::Executable(int id, QString name)
     : EmuFrontObject(id, name), executable(""), options(""), setup(0), type(-1)
index 18cc1bd..b7c5819 100644 (file)
@@ -80,8 +80,11 @@ int DbExecutable::insertDataObjectToModel(const EmuFrontObject* ob)
         "(id, name, executable, options, setupid, type) "
         "VALUES (NULL, :name, :executable, :options, :setupid, :type)");
 
-    q.bindValue(":setupid", ex->getSetup()
-                ? QString(ex->getSetup()->getId()) : "NULL"); // TODO: null shouln't be allowed here
+    if (!ex->getSetup() || ex->getSetup()->getId() < 0) {
+        qDebug() << "Setup not available!";
+        return -1;
+    }
+    q.bindValue(":setupid", ex->getSetup()->getId());
     q.bindValue(":name", ex->getName());
     q.bindValue(":executable", ex->getExecutable());
     q.bindValue(":options", ex->getOptions());
index 877a338..3070e40 100644 (file)
@@ -55,5 +55,6 @@ void ExecutableMainDialog::deleteCurrentObject()
 
 EmuFrontObject* ExecutableMainDialog::createObject()
 {
-    return new Executable;
+    Executable *ex = new Executable;
+    return ex;
 }