Commit 275eff97 authored by Christian Kandeler's avatar Christian Kandeler

QbsProjectManager: Fix infinite loop on per-product build.

- Setting the QFuture result is not enough, we also need to emit the
  finished() signal.
- Never fail silently; use soft asserts for things that shouldn't happen
  and compile pane output for things that can.

Task-number: QBS-705
Change-Id: I4dad18c2ad573a92f2a0c5aa92b596851c56541e
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent dd6331d8
...@@ -365,10 +365,12 @@ void QbsBuildStep::build() ...@@ -365,10 +365,12 @@ void QbsBuildStep::build()
options.setFilesToConsider(m_changedFiles); options.setFilesToConsider(m_changedFiles);
options.setActiveFileTags(m_activeFileTags); options.setActiveFileTags(m_activeFileTags);
m_job = qbsProject()->build(options, m_products); QString error;
m_job = qbsProject()->build(options, m_products, error);
if (!m_job) { if (!m_job) {
emit addOutput(error, ErrorMessageOutput);
m_fi->reportResult(false); m_fi->reportResult(false);
emit finished();
return; return;
} }
......
...@@ -105,6 +105,7 @@ void QbsCleanStep::run(QFutureInterface<bool> &fi) ...@@ -105,6 +105,7 @@ void QbsCleanStep::run(QFutureInterface<bool> &fi)
if (!m_job) { if (!m_job) {
m_fi->reportResult(false); m_fi->reportResult(false);
emit finished();
return; return;
} }
......
...@@ -98,6 +98,7 @@ void QbsInstallStep::run(QFutureInterface<bool> &fi) ...@@ -98,6 +98,7 @@ void QbsInstallStep::run(QFutureInterface<bool> &fi)
if (!m_job) { if (!m_job) {
m_fi->reportResult(false); m_fi->reportResult(false);
emit finished();
return; return;
} }
......
...@@ -344,29 +344,32 @@ void QbsProject::invalidate() ...@@ -344,29 +344,32 @@ void QbsProject::invalidate()
prepareForParsing(); prepareForParsing();
} }
qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts, QStringList productNames) qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts, QStringList productNames,
QString &error)
{ {
if (!qbsProject().isValid() || isParsing()) QTC_ASSERT(qbsProject().isValid(), return 0);
return 0; QTC_ASSERT(!isParsing(), return 0);
if (productNames.isEmpty()) {
if (productNames.isEmpty())
return qbsProject().buildAllProducts(opts); return qbsProject().buildAllProducts(opts);
} else {
QList<qbs::ProductData> products; QList<qbs::ProductData> products;
foreach (const QString &productName, productNames) { foreach (const QString &productName, productNames) {
bool found = false; bool found = false;
foreach (const qbs::ProductData &data, qbsProjectData().allProducts()) { foreach (const qbs::ProductData &data, qbsProjectData().allProducts()) {
if (uniqueProductName(data) == productName) { if (uniqueProductName(data) == productName) {
found = true; found = true;
products.append(data); products.append(data);
break; break;
}
} }
if (!found)
return 0;
} }
if (!found) {
return qbsProject().buildSomeProducts(products, opts); error = QLatin1String("Cannot build: Selected products do not exist anymore."); // TODO: Use tr() in 3.4
return 0;
}
} }
return qbsProject().buildSomeProducts(products, opts);
} }
qbs::CleanJob *QbsProject::clean(const qbs::CleanOptions &opts) qbs::CleanJob *QbsProject::clean(const qbs::CleanOptions &opts)
......
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
const QString &newPath, const qbs::ProductData &productData, const QString &newPath, const qbs::ProductData &productData,
const qbs::GroupData &groupData); const qbs::GroupData &groupData);
qbs::BuildJob *build(const qbs::BuildOptions &opts, QStringList products = QStringList()); qbs::BuildJob *build(const qbs::BuildOptions &opts, QStringList products, QString &error);
qbs::CleanJob *clean(const qbs::CleanOptions &opts); qbs::CleanJob *clean(const qbs::CleanOptions &opts);
qbs::InstallJob *install(const qbs::InstallOptions &opts); qbs::InstallJob *install(const qbs::InstallOptions &opts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment