fix: crash of closeEvent in racewindow and settingsmenu + code cleanup
This commit is contained in:
@@ -121,29 +121,29 @@ WindowRace::WindowRace(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||
tableData = db->getData2(statement, 4);
|
||||
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][0].toStdString();
|
||||
tableData.at(0).at(0).toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][1].toStdString() + " order by seit DESC";
|
||||
tableData.at(0).at(1).toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData2(statement, 1);
|
||||
|
||||
this->ui->gbShell->setTitle("Shell, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][2].toStdString();
|
||||
tableData.at(0).at(2).toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][3].toStdString() + " order by seit DESC";
|
||||
tableData.at(0).at(3).toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData2(statement, 1);
|
||||
|
||||
this->ui->gbDea->setTitle("Dea, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||
|
||||
this->shellDriverId = tableData[0][0].toInt();
|
||||
this->shellCarId = tableData[0][1].toInt();
|
||||
this->deaDriverId = tableData[0][2].toInt();
|
||||
this->deaCarId = tableData[0][3].toInt();
|
||||
this->shellDriverId = tableData.at(0).at(0).toInt();
|
||||
this->shellCarId = tableData.at(0).at(1).toInt();
|
||||
this->deaDriverId = tableData.at(0).at(2).toInt();
|
||||
this->deaCarId = tableData.at(0).at(3).toInt();
|
||||
|
||||
// progressbar
|
||||
this->ui->pbTime->setMaximum(this->fahrzeit);
|
||||
@@ -153,8 +153,9 @@ WindowRace::WindowRace(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||
this->ui->pbTime->setValue(0);
|
||||
|
||||
QKeySequence ks(Qt::Key_Return); // btw, this is numpad enter
|
||||
QShortcut * keyReturn = new QShortcut(ks, this);
|
||||
QObject::connect(keyReturn, SIGNAL(activated()), this, SLOT(ReturnPress()));
|
||||
this->keyReturn = std::make_shared<QShortcut>(ks, this);
|
||||
QObject::connect(keyReturn.get(), SIGNAL(activated()), this,
|
||||
SLOT(ReturnPress()));
|
||||
|
||||
// QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||
}
|
||||
@@ -210,12 +211,12 @@ void WindowRace::prepareNextRace() {
|
||||
this->VecDea.clear();
|
||||
|
||||
// clear tableview shell
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime);
|
||||
ui->lWShellTime->setModel(timeModelShell);
|
||||
timeModelShell = std::make_shared<TimeModel>(VecShell, minSecTime);
|
||||
ui->lWShellTime->setModel(timeModelShell.get());
|
||||
|
||||
// clear tableview dea
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime);
|
||||
ui->lWDeaTime->setModel(timeModelDea);
|
||||
timeModelDea = std::make_shared<TimeModel>(VecDea, minSecTime);
|
||||
ui->lWDeaTime->setModel(timeModelDea.get());
|
||||
|
||||
this->finished = false;
|
||||
this->paused = false;
|
||||
@@ -293,7 +294,7 @@ void WindowRace::closeEvent(QCloseEvent * event) {
|
||||
event->ignore();
|
||||
break;
|
||||
case QMessageBox::Yes:
|
||||
this->wRennliste->schliessen();
|
||||
this->wRennliste->closeRaceList();
|
||||
this->Hardware->setStop();
|
||||
event->accept();
|
||||
break;
|
||||
@@ -362,8 +363,6 @@ WindowRace::~WindowRace() {
|
||||
this->Hardware->setStop();
|
||||
usleep(1000000); // 1 second
|
||||
|
||||
// delete this->db;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
void WindowRace::shellSlot(int time, int sector) {
|
||||
@@ -385,10 +384,10 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
this->timeModelShell = std::make_shared<TimeModel>(
|
||||
VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell.get());
|
||||
|
||||
this->ui->lBridgeShell->setText(QString::number(
|
||||
static_cast<double>(QVectorHelper::getMinSec1(VecShell)) /
|
||||
@@ -405,11 +404,11 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
this->timeModelShell = std::make_shared<TimeModel>(
|
||||
VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
this->ui->lWShellTime->setModel(timeModelShell.get());
|
||||
this->ui->lStraightShell->setText(QString::number(
|
||||
static_cast<double>(
|
||||
QVectorHelper::getMinSec2(VecShell)) /
|
||||
@@ -440,11 +439,11 @@ void WindowRace::shellSlot(int time, int sector) {
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
this->timeModelShell = std::make_shared<TimeModel>(
|
||||
VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
this->ui->lWShellTime->setModel(timeModelShell.get());
|
||||
|
||||
this->ui->lCurvesShell->setText(QString::number(
|
||||
static_cast<double>(
|
||||
@@ -507,8 +506,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
VecDea.push_back(QVector<int>());
|
||||
VecDea.last().push_back(time);
|
||||
cout << "Dea Sektor 1" << endl;
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
timeModelDea =
|
||||
std::make_shared<TimeModel>(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||
|
||||
this->ui->lBridgeDea->setText(QString::number(
|
||||
static_cast<double>(QVectorHelper::getMinSec1(VecDea)) /
|
||||
@@ -520,8 +520,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
if (VecDea.last().size() == 1) {
|
||||
cout << time << sector << endl;
|
||||
VecDea[VecDea.size() - 1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
timeModelDea = std::make_shared<TimeModel>(
|
||||
VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||
this->ui->lStraightDea->setText(QString::number(
|
||||
static_cast<double>(
|
||||
QVectorHelper::getMinSec2(VecDea)) /
|
||||
@@ -544,8 +545,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
||||
VecDea.last().push_back(
|
||||
QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
timeModelDea = std::make_shared<TimeModel>(
|
||||
VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||
}
|
||||
|
||||
// best time on widget
|
||||
@@ -609,13 +611,13 @@ long WindowRace::getMinimum(std::vector<long> a) {
|
||||
long minimum = -1;
|
||||
for (unsigned int i = 0; i < a.size(); i++) {
|
||||
if (minimum < 0) {
|
||||
if (a[i] >= this->minimumTime) {
|
||||
minimum = a[i];
|
||||
if (a.at(i) >= this->minimumTime) {
|
||||
minimum = a.at(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (a[i] < minimum && a[i] >= this->minimumTime) {
|
||||
minimum = a[i];
|
||||
if (a.at(i) < minimum && a.at(i) >= this->minimumTime) {
|
||||
minimum = a.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user