fix crash on close, some code cleanup

This commit is contained in:
2017-09-09 19:45:47 +02:00
parent c963cc37ac
commit 032e354152
3 changed files with 12 additions and 31 deletions

View File

@@ -187,11 +187,11 @@ void HardwareSetup::run(){
emit Shell((int)buffer[i].time, 2);
break;
case 3:
cout << "Time: vor emit" << (int)buffer[i].time << endl;
// cout << "Time: vor emit" << (int)buffer[i].time << endl;
emit Dea((int)buffer[i].time, 2);
break;
case 4:
cout << "emit shell" << endl;
// cout << "emit shell" << endl;
emit Shell((int)buffer[i].time, 3);
break;
case 5:

View File

@@ -113,7 +113,7 @@ QVariant TimeModel::data(const QModelIndex &index, int role) const
bool TimeModel::insertRows(int row, int count, const QModelIndex &parent)
{
std::cout << "insert triggert" << std::endl;
//std::cout << "insert triggert" << std::endl;
beginInsertRows(parent, row, row + count - 1);
// FIXME: Implement me!
endInsertRows();

View File

@@ -104,14 +104,13 @@ void Training::prepareNextRace(){
this->ui->lCurRoundTimeShell->setText("");
this->ui->lCurRoundDea->setText("");
this->finished = false;
this->paused = false;
this->started = true;
}
void Training::shellSlot(int time, int sector){
cout << "Shell slot" << endl;
// cout << "Shell slot" << endl;
// slot is called when a sector is finished
// time is given in ms
// counting of sector beginns at 1
@@ -133,14 +132,11 @@ void Training::shellSlot(int time, int sector){
case 2:
if(VecShell.size() > 0){
if(VecShell.last().size() == 1){
cout << time << sector << endl;
// cout << time << sector << endl;
VecShell.last().push_back(time);
timeModelShell = new TimeModel(VecShell, this);
this->ui->lWShellTime->setModel(timeModelShell);
}
else{
}
}
break;
case 3:
@@ -153,16 +149,9 @@ void Training::shellSlot(int time, int sector){
// add sum to vector
VecShell.last().push_back(QVectorHelper::getCurTime(VecShell.last()));
timeModelShell = new TimeModel(VecShell, this);
this->ui->lWShellTime->setModel(timeModelShell);
}
// best time on widget
if(QVectorHelper::getCurTime(VecShell.last()) <= QVectorHelper::getMin(VecShell)){
@@ -181,7 +170,7 @@ void Training::shellSlot(int time, int sector){
}
void Training::closeEvent(QCloseEvent *event){
Hardware->setStop();
delete this->Hardware;
//delete this->Hardware;
}
void Training::deaSlot(int time, int sector){
@@ -197,7 +186,7 @@ void Training::deaSlot(int time, int sector){
case 1:
VecDea.push_back(QVector<int>());
VecDea.last().push_back(time);
cout << "Dea Sektor 1" << endl;
// cout << "Dea Sektor 1" << endl;
timeModelDea = new TimeModel(VecDea, this);
this->ui->lWDeaTime->setModel(timeModelDea);
@@ -205,7 +194,7 @@ void Training::deaSlot(int time, int sector){
case 2:
if(VecDea.size() > 0){
if(VecDea.last().size() == 1){
cout << time << sector << endl;
// cout << time << sector << endl;
VecDea[VecDea.size()-1].push_back(time);
timeModelDea = new TimeModel(VecDea, this);
this->ui->lWDeaTime->setModel(timeModelDea);
@@ -225,38 +214,30 @@ void Training::deaSlot(int time, int sector){
// add sum to vector
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
timeModelDea = new TimeModel(VecDea, this);
this->ui->lWDeaTime->setModel(timeModelDea);
}
// best time on widget
cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
// cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
// cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
if(QVectorHelper::getCurTime(VecDea.last()) <= QVectorHelper::getMin(VecDea)){
ui->lBestZeitDea->setText(QString::number((double)QVectorHelper::getMin(VecDea)/1000));
}
ui->lCurRoundDea->setText(QString::number((double)QVectorHelper::getCurTime(VecDea.last())/1000));
}
break;
}
ui->lWDeaTime->scrollToBottom();
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
}
}
}
Training::~Training()
{
cout << "destr Training" << endl;
this->Hardware->setStop();
usleep(1000);
usleep(1000000);
delete this->Hardware;
delete ui;
}