From e6c85fa47a076c478ef0b30d92f3b0d29bfbc947 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Nov 2016 13:29:59 +0200 Subject: [PATCH] Calling constructor of Preference dialog take some time. Because of this user have time to call the dialog twice. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 12 ++++++++++-- src/app/valentina/mainwindow.cpp | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 3b60b895c..57f57c10e 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -444,8 +444,16 @@ void TMainWindow::CreateFromExisting() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::Preferences() { - TapeConfigDialog dlg(this); - dlg.exec(); + // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice. + static QPointer guard;// Prevent any second run + if (guard.isNull()) + { + TapeConfigDialog *config = new TapeConfigDialog(this); + // QScopedPointer needs to be sure any exception will never block guard + QScopedPointer dlg(config); + guard = config; + dlg->exec(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 2f678b024..b05a98995 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4017,13 +4017,21 @@ void MainWindow::ShowPaper(int index) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::Preferences() { - ConfigDialog dlg(this); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first - connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles); - if (dlg.exec() == QDialog::Accepted) + // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice. + static QPointer guard;// Prevent any second run + if (guard.isNull()) { - InitAutoSave(); + ConfigDialog *config = new ConfigDialog(this); + // QScopedPointer needs to be sure any exception will never block guard + QScopedPointer dlg(config); + guard = config; + connect(dlg.data(), &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first + connect(dlg.data(), &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); + connect(dlg.data(), &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles); + if (guard->exec() == QDialog::Accepted) + { + InitAutoSave(); + } } }