From 51893d9f4a098013100b72f3b968da60955af43b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 25 Jun 2019 11:08:47 +0300 Subject: [PATCH] Refactoring. Use QScopeGuard. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index d2c600fc8..4ccf8d572 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -65,6 +65,12 @@ #include "../qmuparser/qmuparsererror.h" #include "../vtools/dialogs/support/dialogeditlabel.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) +#include "../vmisc/backport/qscopeguard.h" +#else +#include +#endif + #include #include #include @@ -4928,11 +4934,12 @@ void MainWindow::CreateMeasurements() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ExportLayoutAs() { + auto Uncheck = qScopeGuard([this] {ui->toolButtonLayoutExportAs->setChecked(false);}); + if (isLayoutStale) { if (ContinueIfLayoutStale() == QMessageBox::No) { - ui->toolButtonLayoutExportAs->setChecked(false); return; } } @@ -4945,7 +4952,6 @@ void MainWindow::ExportLayoutAs() if (m_dialogSaveLayout->exec() == QDialog::Rejected) { m_dialogSaveLayout.clear(); - ui->toolButtonLayoutExportAs->setChecked(false); return; } @@ -4955,17 +4961,17 @@ void MainWindow::ExportLayoutAs() catch (const VException &e) { m_dialogSaveLayout.clear(); - ui->toolButtonLayoutExportAs->setChecked(false); qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); return; } - ui->toolButtonLayoutExportAs->setChecked(false); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ExportDetailsAs() { + auto Uncheck = qScopeGuard([this] {ui->toolButtonDetailExportAs->setChecked(false);}); + QVector detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); if (detailsInLayout.count() == 0) @@ -4997,7 +5003,6 @@ void MainWindow::ExportDetailsAs() if (m_dialogSaveLayout->exec() == QDialog::Rejected) { m_dialogSaveLayout.clear(); - ui->toolButtonDetailExportAs->setChecked(false); return; } @@ -5007,12 +5012,10 @@ void MainWindow::ExportDetailsAs() catch (const VException &e) { m_dialogSaveLayout.clear(); - ui->toolButtonDetailExportAs->setChecked(false); qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); return; } - ui->toolButtonDetailExportAs->setChecked(false); } //---------------------------------------------------------------------------------------------------------------------