1111#include " core/task.h"
1212#include " core/testcase.h"
1313#include " exttestcaseupdaterdialog.h"
14+ //
15+ #include < memory>
1416
1517ExtTestCaseModifier::ExtTestCaseModifier (QWidget *parent) : QWidget(parent), ui(new Ui::ExtTestCaseModifier) {
1618 ui->setupUi (this );
@@ -63,8 +65,8 @@ void ExtTestCaseModifier::modifySelected() {
6365 int l = hav.front (), r = hav.back ();
6466
6567 if (l != r) {
66- auto * dialog = new ExtTestCaseUpdaterDialog ( this , editTask, editSettings, - 1 , MAY_EDIT , NO_EDIT ,
67- MAY_EDIT , MAY_EDIT , NO_EDIT );
68+ auto dialog = std::make_unique< ExtTestCaseUpdaterDialog>(
69+ this , editTask, editSettings, - 1 , MAY_EDIT , NO_EDIT , MAY_EDIT , MAY_EDIT , NO_EDIT );
6870
6971 if (dialog->exec () == QDialog::Accepted) {
7072 auto sc = dialog->getScore ();
@@ -82,10 +84,8 @@ void ExtTestCaseModifier::modifySelected() {
8284 editTask->getTestCase (i)->setMemoryLimit (ml);
8385 }
8486 }
85-
86- delete dialog;
8787 } else {
88- auto * dialog = new ExtTestCaseUpdaterDialog (
88+ auto dialog = std::make_unique< ExtTestCaseUpdaterDialog> (
8989 this , editTask, editSettings, l + 1 , editTask->getTestCase (l)->getFullScore (), NO_EDIT ,
9090 editTask->getTestCase (l)->getTimeLimit (), editTask->getTestCase (l)->getMemoryLimit (), 1 ,
9191 editTask->getTestCase (l)->getDependenceSubtask ());
@@ -96,14 +96,12 @@ void ExtTestCaseModifier::modifySelected() {
9696 editTask->getTestCase (l)->setMemoryLimit (dialog->getMemoryLimit ());
9797 editTask->getTestCase (l)->setDependenceSubtask (dialog->getDepends ());
9898 }
99-
100- delete dialog;
10199 }
102100 } else {
103101 int who = res.front ().first , loc = res.front ().second .first ;
104102
105- auto * dialog = new ExtTestCaseUpdaterDialog (this , editTask, editSettings, -1 , NO_EDIT , 1 , NO_EDIT ,
106- NO_EDIT , NO_EDIT );
103+ auto dialog = std::make_unique< ExtTestCaseUpdaterDialog> (this , editTask, editSettings, -1 , NO_EDIT , 1 ,
104+ NO_EDIT , NO_EDIT , NO_EDIT );
107105
108106 if (dialog->exec () == QDialog::Accepted) {
109107 editTask->getTestCase (who)->setInputFiles (loc, dialog->getInput ());
@@ -375,9 +373,9 @@ void ExtTestCaseModifier::splitSelected() {
375373}
376374
377375void ExtTestCaseModifier::appendNewSub () {
378- auto * dialog =
379- new ExtTestCaseUpdaterDialog ( this , editTask, editSettings, editTask->getTestCaseList ().size () + 1 ,
380- EDIT_WITH_DEFAULT , 1 , EDIT_WITH_DEFAULT , EDIT_WITH_DEFAULT , 1 );
376+ auto dialog = std::make_unique<ExtTestCaseUpdaterDialog>(
377+ this , editTask, editSettings, editTask->getTestCaseList ().size () + 1 , EDIT_WITH_DEFAULT , 1 ,
378+ EDIT_WITH_DEFAULT , EDIT_WITH_DEFAULT , 1 );
381379
382380 if (dialog->exec () == QDialog::Accepted) {
383381 auto *now = new TestCase;
@@ -390,22 +388,18 @@ void ExtTestCaseModifier::appendNewSub() {
390388 editTask->addTestCase (now);
391389 }
392390
393- delete dialog;
394-
395391 refresh ();
396392}
397393
398394void ExtTestCaseModifier::appendNewCase () {
399395 int who = ui->testCaseTable ->getSelectedHaveSub ().constLast ();
400396
401- auto * dialog = new ExtTestCaseUpdaterDialog (this , editTask, editSettings, who + 1 , NO_EDIT , 1 , NO_EDIT ,
402- NO_EDIT , NO_EDIT );
397+ auto dialog = std::make_unique< ExtTestCaseUpdaterDialog> (this , editTask, editSettings, who + 1 , NO_EDIT ,
398+ 1 , NO_EDIT , NO_EDIT , NO_EDIT );
403399
404400 if (dialog->exec () == QDialog::Accepted) {
405401 editTask->getTestCase (who)->addSingleCase (dialog->getInput (), dialog->getOutput ());
406402 }
407403
408- delete dialog;
409-
410404 refresh ();
411405}
0 commit comments