Procházet zdrojové kódy

added Qt::WA_DeleteOnClose for dialogues

fiffty-50 před 4 roky
rodič
revize
3778b482b8

+ 4 - 6
src/gui/widgets/aircraftwidget.cpp

@@ -128,9 +128,8 @@ void AircraftWidget::on_newButton_clicked()
     auto nt = new NewTailDialog(QString(), Db::createNew, this);
     connect(nt, SIGNAL(accepted()), this, SLOT(acft_editing_finished()));
     connect(nt, SIGNAL(rejected()), this, SLOT(acft_editing_finished()));
-    if(nt->exec() == QDialog::Accepted || QDialog::Rejected) {
-        delete nt;
-    }
+    nt->setAttribute(Qt::WA_DeleteOnClose);
+    nt->exec();
 }
 
 void AircraftWidget::on_searchLineEdit_textChanged(const QString &arg1)
@@ -155,11 +154,10 @@ void AircraftWidget::tableView_selectionChanged()
         connect(nt, SIGNAL(accepted()), this, SLOT(acft_editing_finished()));
         connect(nt, SIGNAL(rejected()), this, SLOT(acft_editing_finished()));
         nt->setWindowFlag(Qt::Widget);
+        nt->setAttribute(Qt::WA_DeleteOnClose);
         ui->stackedWidget->addWidget(nt);
         ui->stackedWidget->setCurrentWidget(nt);
-        if(nt->exec() == QDialog::Accepted || QDialog::Rejected) {
-            delete nt;
-        }
+        nt->exec();
     }
 }
 

+ 3 - 3
src/gui/widgets/logbookwidget.cpp

@@ -68,9 +68,8 @@ void LogbookWidget::refreshView(int view_id)
     view->verticalHeader()->hide();
     view->setAlternatingRowColors(true);
     view->hideColumn(0);
-    connect(ui->tableView->selectionModel(),
-            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
-            SLOT(tableView_selectionChanged()));
+    connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            this, SLOT(tableView_selectionChanged()));
 }
 
 void LogbookWidget::defaultView()
@@ -150,6 +149,7 @@ void LogbookWidget::tableView_selectionChanged()//
 void LogbookWidget::on_newFlightButton_clicked()
 {
     NewFlightDialog nf(this, Db::createNew);
+    nf.setAttribute(Qt::WA_DeleteOnClose);
     nf.exec();
     refreshView(Settings::read("logbook/view").toInt());
 }

+ 6 - 9
src/gui/widgets/pilotswidget.cpp

@@ -51,12 +51,11 @@ void PilotsWidget::tableView_selectionChanged()//const QItemSelection &index, co
         connect(np, SIGNAL(accepted()), this, SLOT(pilot_editing_finished()));
         connect(np, SIGNAL(rejected()), this, SLOT(pilot_editing_finished()));
         np->setWindowFlag(Qt::Widget);
+        np->setAttribute(Qt::WA_DeleteOnClose);
         ui->stackedWidget->addWidget(np);
         ui->stackedWidget->setCurrentWidget(np);
 
-        if(np->exec() == QDialog::Accepted || QDialog::Rejected) {
-            delete np;
-        }
+        np->exec();
     }
 }
 
@@ -69,12 +68,10 @@ void PilotsWidget::tableView_headerClicked(int column)
 void PilotsWidget::on_newButton_clicked()
 {
     NewPilotDialog* np = new NewPilotDialog(Db::createNew, this);
-    connect(np,
-            SIGNAL(accepted()), this,
-            SLOT(pilot_editing_finished()));
-    if(np->exec() == QDialog::Accepted || QDialog::Rejected) {
-        delete np;
-    }
+    connect(np, SIGNAL(accepted()),
+            this, SLOT(pilot_editing_finished()));
+    np->setAttribute(Qt::WA_DeleteOnClose);
+    np->exec();
 }
 
 void PilotsWidget::on_deletePushButton_clicked()