replaced pointer by smart pointers
This commit is contained in:
@@ -15,7 +15,7 @@ using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
WindowRace::WindowRace(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowRace) {
|
||||
ui->setupUi(this);
|
||||
this->ui->pBNextRace->setEnabled(false);
|
||||
@@ -27,12 +27,12 @@ WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
|
||||
vector<vector<QString>> res;
|
||||
res = db->getData("select dauer from renndauer", 1);
|
||||
this->fahrzeit = res[0][0].toInt();
|
||||
this->fahrzeit = res.at(0).at(0).toInt();
|
||||
|
||||
string statement =
|
||||
"select minimumroundtime from rennen order by id DESC limit 1";
|
||||
res = db->getData(statement, 1);
|
||||
this->minimumTime = res[0][0].toInt();
|
||||
this->minimumTime = res.at(0).at(0).toInt();
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3, mindestRundenDauer from "
|
||||
@@ -40,10 +40,10 @@ WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
"DESC limit 1";
|
||||
// cout << statement << endl;
|
||||
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());
|
||||
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);
|
||||
@@ -55,28 +55,28 @@ WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
firstTimeShell = true;
|
||||
started = false;
|
||||
countdownValue = this->fahrzeit;
|
||||
countdown = new Countdown;
|
||||
countdown = std::make_shared<Countdown>();
|
||||
|
||||
startAmpelThread = new Ampel;
|
||||
startAmpelThread = std::make_shared<Ampel>();
|
||||
ampelCounter = 0;
|
||||
|
||||
ui->pBStart->setFocus();
|
||||
|
||||
paused = false;
|
||||
|
||||
Hardware = new HardwareSetup;
|
||||
Hardware = std::make_shared<HardwareSetup>();
|
||||
Hardware->start();
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
|
||||
QObject::connect(Hardware.get(), SIGNAL(Dea(int, int)), this,
|
||||
SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
|
||||
QObject::connect(Hardware.get(), SIGNAL(Shell(int, int)), this,
|
||||
SLOT(shellSlot(int, int)));
|
||||
QObject::connect(ui->pBStart, SIGNAL(clicked()), this, SLOT(go()));
|
||||
QObject::connect(countdown, SIGNAL(CountdownUpdate()), this,
|
||||
QObject::connect(countdown.get(), SIGNAL(CountdownUpdate()), this,
|
||||
SLOT(countdownUpdate()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
QObject::connect(startAmpelThread.get(), SIGNAL(ampelUpdate()), this,
|
||||
SLOT(ampelSlot()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
QObject::connect(startAmpelThread.get(), SIGNAL(ampelUpdate()), this,
|
||||
SLOT(laufcheck()));
|
||||
QObject::connect(ui->pBBreak, SIGNAL(clicked()), this,
|
||||
SLOT(breakCounter()));
|
||||
@@ -264,18 +264,19 @@ void WindowRace::stopClicked() {
|
||||
this->prepareNextRace();
|
||||
}
|
||||
|
||||
void WindowRace::setWindowRennliste(WindowRennliste * ptrInstance) {
|
||||
void WindowRace::setWindowRennliste(
|
||||
std::shared_ptr<WindowRennliste> ptrInstance) {
|
||||
|
||||
this->wRennliste = ptrInstance;
|
||||
this->wRennlisteSeted = true;
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste,
|
||||
SLOT(changeSelection()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()),
|
||||
this->wRennliste.get(), SLOT(changeSelection()));
|
||||
}
|
||||
void WindowRace::setDriverAndCarId(vector<QString> vec) {
|
||||
this->shellDriverId = vec[0].toInt();
|
||||
this->shellCarId = vec[1].toInt();
|
||||
this->deaDriverId = vec[2].toInt();
|
||||
this->deaCarId = vec[3].toInt();
|
||||
this->shellDriverId = vec.at(0).toInt();
|
||||
this->shellCarId = vec.at(1).toInt();
|
||||
this->deaDriverId = vec.at(2).toInt();
|
||||
this->deaCarId = vec.at(3).toInt();
|
||||
}
|
||||
void WindowRace::closeEvent(QCloseEvent * event) {
|
||||
countdown->setStop();
|
||||
@@ -359,11 +360,7 @@ WindowRace::~WindowRace() {
|
||||
this->startAmpelThread->setStop();
|
||||
this->countdown->setStop();
|
||||
this->Hardware->setStop();
|
||||
usleep(1000010); // eine Sekunde
|
||||
|
||||
delete this->countdown;
|
||||
delete this->Hardware;
|
||||
delete this->startAmpelThread;
|
||||
usleep(1000000); // 1 second
|
||||
|
||||
// delete this->db;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user