From 696129296ad3748a2eaade0f6f9ab0b77b8f1af8 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 5 Aug 2024 15:48:03 +0200 Subject: [PATCH] JsonWizard: Show error if some files fail to generate Do not overwrite error messages by an empty string, if the last file in the list successfully is determined. Also do not show the error message twice by avoiding the summarySettingsHaveChanged() call at the end of initialize(), which tries to contruct the generated file list again. Change-Id: Icaa329fcdd8882d49c4776aaced23e0094cfe857 Reviewed-by: Christian Stenger --- .../jsonwizard/jsonsummarypage.cpp | 7 +++++++ .../jsonwizard/jsonwizardfilegenerator.cpp | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp index 8db6d46cac9..a5a6b7582a0 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp @@ -90,7 +90,14 @@ void JsonSummaryPage::initializePage() connect(m_wizard, &JsonWizard::filesReady, this, &JsonSummaryPage::triggerCommit); connect(m_wizard, &JsonWizard::filesReady, this, &JsonSummaryPage::addToProject); + // set result to accepted, so we can check if updateFileList -> m_wizard->generateFileList + // called reject() + m_wizard->setResult(QDialog::Accepted); updateFileList(); + // if there were errors while updating the file list, the dialog is rejected + // so don't continue the setup (which also avoids showing the error message again) + if (m_wizard->result() == QDialog::Rejected) + return; IWizardFactory::WizardKind kind = wizardKind(m_wizard); bool isProject = (kind == IWizardFactory::ProjectWizard); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp index c6f6900d045..e48f93e9928 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp @@ -238,13 +238,17 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(MacroExpander *expander, } const Core::GeneratedFiles result - = Utils::transform(fileList, - [this, &expander, &errorMessage](const File &f) { - return generateFile(f, expander, errorMessage); - }); + = Utils::transform(fileList, [this, &expander, &errorMessage](const File &f) { + QString generateError; + const Core::GeneratedFile file = generateFile(f, expander, &generateError); + if (!generateError.isEmpty()) + *errorMessage = generateError; + return file; + }); - if (Utils::contains(result, - [](const Core::GeneratedFile &gf) { return gf.filePath().isEmpty(); })) + if (Utils::contains(result, [](const Core::GeneratedFile &gf) { + return gf.filePath().isEmpty(); + })) return Core::GeneratedFiles(); return result;