diff --git a/database.cpp b/database.cpp index 9d99040..4608486 100644 --- a/database.cpp +++ b/database.cpp @@ -50,7 +50,6 @@ vector> DataBase::getData(std::string statement, int cols) { bool ok = this->db->open(); QString qstr; if (ok) { - std::cout << "alles ok bis hier" << std::endl; QSqlQuery query(buffer); while (query.next()) { diff --git a/training.cpp b/training.cpp index 4d045d1..113e834 100644 --- a/training.cpp +++ b/training.cpp @@ -22,7 +22,15 @@ Training::Training(QWidget * parent, DataBase * db) string statement = "select mindestrundendauer from renndauer where id like 1"; - this->minimumTime = this->db->getData(statement, 1)[0][0].toInt(); + vector> mintime = this->db->getData(statement, 1); + if (mintime.size() > 0) { + if (mintime.at(0).size() > 0) { + this->minimumTime = mintime.at(0).at(0).toInt(); + } + } + else { + cout << "missing database :(" << endl; + } this->finished = false; firstTimeDea = true; @@ -61,16 +69,22 @@ Training::Training(QWidget * parent, DataBase * db) "renndauer order by id " "DESC limit 1"; vector> res; - res = db->getData(statement, 4); - this->minSecTime.append(res[0][0].toInt()); - this->minSecTime.append(res[0][1].toInt()); - this->minSecTime.append(res[0][2].toInt()); - this->minSecTime.append(res[0][3].toInt()); + try { + res = db->getData(statement, 4); + this->minSecTime.append(res.at(0).at(0).toInt()); + this->minSecTime.append(res.at(0).at(1).toInt()); + this->minSecTime.append(res.at(0).at(2).toInt()); + this->minSecTime.append(res.at(0).at(3).toInt()); - QVectorHelper::minSec1 = this->minSecTime.at(0); - QVectorHelper::minSec2 = this->minSecTime.at(1); - QVectorHelper::minSec3 = this->minSecTime.at(2); - QVectorHelper::minTrackTime = this->minSecTime.at(3); + QVectorHelper::minSec1 = this->minSecTime.at(0); + QVectorHelper::minSec2 = this->minSecTime.at(1); + QVectorHelper::minSec3 = this->minSecTime.at(2); + QVectorHelper::minTrackTime = this->minSecTime.at(3); + + } catch (const std::exception & e) { + Q_UNUSED(e); + cout << "missing database :(" << endl; + } } void Training::ResetShell() { this->VecShell.clear();