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(); + } } }