From 151373396fc52de763eff05da0b0071130f521db Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 26 Aug 2020 14:30:43 +0200 Subject: [PATCH] QbsProjectManager: Fix install step We got the install command name wrong, which caused the installation to fail. In addition, we forgot to add handling for the "protocol-error" message from qbs, so the step was hanging, rather than aborting. Finally, we triggered a number of assertions in BuildStep::buildConfiguration(). This went all unnoticed for a while, because the install step is not enabled by default these days. Change-Id: I906e7e472563d4ad8fc7557bd706a7cb67f9f2ba Reviewed-by: hjk --- src/plugins/projectexplorer/buildstep.cpp | 8 +++++--- src/plugins/qbsprojectmanager/qbsinstallstep.cpp | 8 ++++---- src/plugins/qbsprojectmanager/qbssession.cpp | 11 ++++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 39a2e647fdc..ad93d4bf4b2 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -265,9 +265,11 @@ QString BuildStep::fallbackWorkingDirectory() const void BuildStep::setupOutputFormatter(OutputFormatter *formatter) { - for (const Utils::Id id : buildConfiguration()->customParsers()) { - if (Internal::CustomParser * const parser = Internal::CustomParser::createFromId(id)) - formatter->addLineParser(parser); + if (qobject_cast(parent()->parent())) { + for (const Utils::Id id : buildConfiguration()->customParsers()) { + if (Internal::CustomParser * const parser = Internal::CustomParser::createFromId(id)) + formatter->addLineParser(parser); + } } Utils::FileInProjectFinder fileFinder; fileFinder.setProjectDirectory(project()->projectDirectory()); diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp index 86f0368422b..f7206c70281 100644 --- a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp @@ -109,16 +109,16 @@ QbsInstallStep::~QbsInstallStep() bool QbsInstallStep::init() { - QTC_ASSERT(!buildSystem()->isParsing() && !m_session, return false); + QTC_ASSERT(!target()->buildSystem()->isParsing() && !m_session, return false); return true; } void QbsInstallStep::doRun() { - m_session = static_cast(buildSystem())->session(); + m_session = static_cast(target()->buildSystem())->session(); QJsonObject request; - request.insert("type", "install"); + request.insert("type", "install-project"); request.insert("install-root", installRoot()); request.insert("clean-install-root", m_cleanInstallRoot); request.insert("keep-going", m_keepGoing); @@ -153,7 +153,7 @@ QString QbsInstallStep::installRoot() const const QbsBuildConfiguration *QbsInstallStep::buildConfig() const { - return static_cast(buildConfiguration()); + return static_cast(target()->activeBuildConfiguration()); } bool QbsInstallStep::fromMap(const QVariantMap &map) diff --git a/src/plugins/qbsprojectmanager/qbssession.cpp b/src/plugins/qbsprojectmanager/qbssession.cpp index f03b4176efb..361109db67d 100644 --- a/src/plugins/qbsprojectmanager/qbssession.cpp +++ b/src/plugins/qbsprojectmanager/qbssession.cpp @@ -267,7 +267,7 @@ QString QbsSession::errorString(QbsSession::Error error) case Error::QbsFailedToStart: return tr("The qbs process failed to start."); case Error::ProtocolError: - return tr("The qbs process sent invalid data."); + return tr("The qbs process sent unexpected data."); case Error::VersionMismatch: return tr("The qbs API level is not compatible with what Qt Creator expects."); } @@ -534,6 +534,15 @@ void QbsSession::handlePacket(const QJsonObject &packet) } else if (type == "run-environment") { d->reply = packet; d->eventLoop.quit(); + } else if (type == "protocol-error") { + const ErrorInfo errorInfo = ErrorInfo(packet.value("error").toObject()); + + // TODO: This loop occurs a lot. Factor it out. + for (const ErrorInfoItem &item : errorInfo.items) { + TaskHub::addTask(BuildSystemTask(Task::Error, item.description, + item.filePath, item.line)); + } + setError(Error::ProtocolError); } }