From 916a78f05014f1f1d1d9d6b5f4480b860cb1701b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 12 Apr 2016 12:36:12 +0200 Subject: [PATCH] New Dialog: Don't not stay in NewDialog after calling QDialog::accept Accept closes the dialog, and the dialog is flagged as DeleteOnClose. So we may not run the wizard from it directly. Regression introduced by 2cd5b448e13c733046e6904df78ff97ac1b28104 Change-Id: Ic2e4ed436cb8f9e02cc987ff5156c2c4e832b4fb Task-number: QTCREATORBUG-15968 Reviewed-by: Tobias Hunger --- src/plugins/coreplugin/dialogs/newdialog.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index 0a7ed68f19e..013779f83da 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -41,6 +41,7 @@ #include #include #include +#include Q_DECLARE_METATYPE(Core::IWizardFactory*) @@ -458,17 +459,25 @@ void NewDialog::saveState() ICore::settings()->setValue(QLatin1String(LAST_PLATFORM_KEY), m_ui->comboBox->currentData()); } +static void runWizard(IWizardFactory *wizard, const QString &defaultLocation, Id platform, + const QVariantMap &variables) +{ + QString path = wizard->runPath(defaultLocation); + wizard->runWizard(path, ICore::dialogParent(), platform, variables); +} + void NewDialog::accept() { saveState(); - QDialog::accept(); - if (m_ui->templatesView->currentIndex().isValid()) { IWizardFactory *wizard = currentWizardFactory(); - QTC_ASSERT(wizard, accept(); return); - QString path = wizard->runPath(m_defaultLocation); - wizard->runWizard(path, ICore::dialogParent(), selectedPlatform(), m_extraVariables); + QTC_CHECK(wizard); + if (wizard) { + QTimer::singleShot(0, std::bind(&runWizard, wizard, m_defaultLocation, + selectedPlatform(), m_extraVariables)); + } } + QDialog::accept(); } void NewDialog::reject()