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 <christian.stenger@qt.io>
This commit is contained in:
Eike Ziller
2024-08-05 15:48:03 +02:00
parent 9a8cba372b
commit 696129296a
2 changed files with 17 additions and 6 deletions

View File

@@ -90,7 +90,14 @@ void JsonSummaryPage::initializePage()
connect(m_wizard, &JsonWizard::filesReady, this, &JsonSummaryPage::triggerCommit); connect(m_wizard, &JsonWizard::filesReady, this, &JsonSummaryPage::triggerCommit);
connect(m_wizard, &JsonWizard::filesReady, this, &JsonSummaryPage::addToProject); 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(); 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); IWizardFactory::WizardKind kind = wizardKind(m_wizard);
bool isProject = (kind == IWizardFactory::ProjectWizard); bool isProject = (kind == IWizardFactory::ProjectWizard);

View File

@@ -238,13 +238,17 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(MacroExpander *expander,
} }
const Core::GeneratedFiles result const Core::GeneratedFiles result
= Utils::transform(fileList, = Utils::transform(fileList, [this, &expander, &errorMessage](const File &f) {
[this, &expander, &errorMessage](const File &f) { QString generateError;
return generateFile(f, expander, errorMessage); const Core::GeneratedFile file = generateFile(f, expander, &generateError);
if (!generateError.isEmpty())
*errorMessage = generateError;
return file;
}); });
if (Utils::contains(result, if (Utils::contains(result, [](const Core::GeneratedFile &gf) {
[](const Core::GeneratedFile &gf) { return gf.filePath().isEmpty(); })) return gf.filePath().isEmpty();
}))
return Core::GeneratedFiles(); return Core::GeneratedFiles();
return result; return result;