Calling constructor of Preference dialog take some time. Because of this user

have time to call the dialog twice.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-11-04 13:29:59 +02:00
parent 595a7dcaff
commit e6c85fa47a
2 changed files with 24 additions and 8 deletions

View file

@ -444,8 +444,16 @@ void TMainWindow::CreateFromExisting()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::Preferences() void TMainWindow::Preferences()
{ {
TapeConfigDialog dlg(this); // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice.
dlg.exec(); static QPointer<TapeConfigDialog> 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<TapeConfigDialog> dlg(config);
guard = config;
dlg->exec();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -4017,13 +4017,21 @@ void MainWindow::ShowPaper(int index)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::Preferences() void MainWindow::Preferences()
{ {
ConfigDialog dlg(this); // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice.
connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first static QPointer<ConfigDialog> guard;// Prevent any second run
connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); if (guard.isNull())
connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles);
if (dlg.exec() == QDialog::Accepted)
{ {
InitAutoSave(); ConfigDialog *config = new ConfigDialog(this);
// QScopedPointer needs to be sure any exception will never block guard
QScopedPointer<ConfigDialog> 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();
}
} }
} }