fix segfault if no database is available
This commit is contained in:
@@ -50,7 +50,6 @@ vector<vector<QString>> DataBase::getData(std::string statement, int cols) {
|
|||||||
bool ok = this->db->open();
|
bool ok = this->db->open();
|
||||||
QString qstr;
|
QString qstr;
|
||||||
if (ok) {
|
if (ok) {
|
||||||
std::cout << "alles ok bis hier" << std::endl;
|
|
||||||
QSqlQuery query(buffer);
|
QSqlQuery query(buffer);
|
||||||
|
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
|
|||||||
34
training.cpp
34
training.cpp
@@ -22,7 +22,15 @@ Training::Training(QWidget * parent, DataBase * db)
|
|||||||
string statement =
|
string statement =
|
||||||
"select mindestrundendauer from renndauer where id like 1";
|
"select mindestrundendauer from renndauer where id like 1";
|
||||||
|
|
||||||
this->minimumTime = this->db->getData(statement, 1)[0][0].toInt();
|
vector<vector<QString>> 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;
|
this->finished = false;
|
||||||
|
|
||||||
firstTimeDea = true;
|
firstTimeDea = true;
|
||||||
@@ -61,16 +69,22 @@ Training::Training(QWidget * parent, DataBase * db)
|
|||||||
"renndauer order by id "
|
"renndauer order by id "
|
||||||
"DESC limit 1";
|
"DESC limit 1";
|
||||||
vector<vector<QString>> res;
|
vector<vector<QString>> res;
|
||||||
res = db->getData(statement, 4);
|
try {
|
||||||
this->minSecTime.append(res[0][0].toInt());
|
res = db->getData(statement, 4);
|
||||||
this->minSecTime.append(res[0][1].toInt());
|
this->minSecTime.append(res.at(0).at(0).toInt());
|
||||||
this->minSecTime.append(res[0][2].toInt());
|
this->minSecTime.append(res.at(0).at(1).toInt());
|
||||||
this->minSecTime.append(res[0][3].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::minSec1 = this->minSecTime.at(0);
|
||||||
QVectorHelper::minSec2 = this->minSecTime.at(1);
|
QVectorHelper::minSec2 = this->minSecTime.at(1);
|
||||||
QVectorHelper::minSec3 = this->minSecTime.at(2);
|
QVectorHelper::minSec3 = this->minSecTime.at(2);
|
||||||
QVectorHelper::minTrackTime = this->minSecTime.at(3);
|
QVectorHelper::minTrackTime = this->minSecTime.at(3);
|
||||||
|
|
||||||
|
} catch (const std::exception & e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
cout << "missing database :(" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Training::ResetShell() {
|
void Training::ResetShell() {
|
||||||
this->VecShell.clear();
|
this->VecShell.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user