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 2cd5b448e1

Change-Id: Ic2e4ed436cb8f9e02cc987ff5156c2c4e832b4fb
Task-number: QTCREATORBUG-15968
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Eike Ziller
2016-04-12 12:36:12 +02:00
parent 51a6dadc77
commit 916a78f050

View File

@@ -41,6 +41,7 @@
#include <QPushButton>
#include <QSortFilterProxyModel>
#include <QStandardItem>
#include <QTimer>
Q_DECLARE_METATYPE(Core::IWizardFactory*)
@@ -458,18 +459,26 @@ 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()
{