From 89d0e41835128631e6672c9a62e77b94ecbcdb50 Mon Sep 17 00:00:00 2001 From: Romain DERRE <romain.derre@pc228-14.pedago.ensiie.fr> Date: Fri, 29 Mar 2019 14:23:19 +0100 Subject: [PATCH] =?UTF-8?q?removeTask=20op=C3=A9rationnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/elementstablemodel.cpp | 15 +++++++++++---- app/mainwindow.cpp | 10 ++++++++++ app/mainwindow.h | 4 ++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/elementstablemodel.cpp b/app/elementstablemodel.cpp index c116ca7..302b7dc 100644 --- a/app/elementstablemodel.cpp +++ b/app/elementstablemodel.cpp @@ -113,6 +113,8 @@ void ElementsTableModel::removeTask(Task* task){ //int row = pidVector.indexOf(key); beginRemoveRows(QModelIndex(), rowCount(), rowCount()); taskVector.removeOne(task); + free(task); + qDebug() << "free"; //pidVector.remove(row); //qDebug() << "remove " << task->print(); endRemoveRows(); @@ -166,9 +168,9 @@ void ElementsTableModel::update() timer.start(); //QVector<Task*>::iterator it; - for (int i =0; i < taskVector.size(); ++i) + for (int j =0; j < taskVector.size(); ++j) { - taskVector.value(i)->setExist(false); + taskVector.value(j)->setExist(false); } @@ -219,12 +221,17 @@ void ElementsTableModel::update() //qDebug() << "search in map :" << timer.elapsed() << "milliseconds"; //qDebug() << test.print("|"); - } task_list.close(); - //usleep(10000); + for (int i = 0; i < taskVector.size(); ++i) + { + if(!taskVector.value(i)->isExist()) + { + removeTask(taskVector.value(i)); + } + } } diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 4addf8a..7b93e32 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -125,3 +125,13 @@ void MainWindow::on_comboBox_currentTextChanged(const QString &arg1) } + +void MainWindow::on_actionQuitter_triggered() +{ + +} + +void MainWindow::on_actionQuit_triggered() +{ + on_actionQuitter_triggered(); +} diff --git a/app/mainwindow.h b/app/mainwindow.h index 7adf44e..1d1107d 100644 --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -39,6 +39,10 @@ private slots: void on_comboBox_currentTextChanged(const QString &arg1); + void on_actionQuitter_triggered(); + + void on_actionQuit_triggered(); + private: Ui::MainWindow *ui; int PIDselected; -- GitLab