From 553c3c2c74f631598dfda3e8a026ed1dc358626a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 31 Mar 2020 20:25:54 +0200 Subject: [PATCH] Android: Use the new Target::activeBuildKey() function Change-Id: I051874a2b44129740b2ecc19f7ff401663d8bf0a Reviewed-by: Christian Kandeler --- src/plugins/android/androidbuildapkstep.cpp | 18 ++++++++--------- src/plugins/android/androidbuildapkwidget.cpp | 5 ++--- src/plugins/android/androiddeployqtstep.cpp | 3 ++- .../android/androidextralibrarylistmodel.cpp | 20 +++++++++---------- .../android/createandroidmanifestwizard.cpp | 6 ++---- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index e13eafd4cbf..c4341ab1e9b 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -40,11 +40,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -181,9 +181,8 @@ bool AndroidBuildApkStep::init() parser->setProjectFileList(Utils::transform(target()->project()->files(ProjectExplorer::Project::AllFiles), &Utils::FilePath::toString)); - RunConfiguration *rc = target()->activeRunConfiguration(); - const QString buildKey = rc ? rc->buildKey() : QString(); - const ProjectNode *node = rc ? target()->project()->findNodeForBuildKey(buildKey) : nullptr; + const QString buildKey = target()->activeBuildKey(); + const ProjectNode *node = target()->project()->findNodeForBuildKey(buildKey); QString sourceDirName; if (node) @@ -222,7 +221,7 @@ bool AndroidBuildApkStep::init() m_inputFile = node->data(Constants::AndroidDeploySettingsFile).toString(); if (m_inputFile.isEmpty()) { - qCDebug(buildapkstepLog) << "no input file" << rc << node << buildKey; + qCDebug(buildapkstepLog) << "no input file" << node << buildKey; m_skipBuilding = true; return true; } @@ -384,9 +383,8 @@ void AndroidBuildApkStep::doRun() return false; } - RunConfiguration *rc = target()->activeRunConfiguration(); - const QString buildKey = rc ? rc->buildKey() : QString(); - const ProjectNode *node = rc ? target()->project()->findNodeForBuildKey(buildKey) : nullptr; + const QString buildKey = target()->activeBuildKey(); + const ProjectNode *node = target()->project()->findNodeForBuildKey(buildKey); if (!node) return false; @@ -408,7 +406,7 @@ void AndroidBuildApkStep::doRun() QString applicationBinary; if (version->qtVersion() < QtSupport::QtVersionNumber(5, 14, 0)) { QTC_ASSERT(androidAbis.size() == 1, return false); - applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toString(); + applicationBinary = buildSystem()->buildTarget(buildKey).targetFilePath.toString(); Utils::FilePath androidLibsDir = buildDirectory().pathAppended("android-build/libs").pathAppended(androidAbis.first()); for (const auto &target : targets) { if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString())) @@ -416,7 +414,7 @@ void AndroidBuildApkStep::doRun() } deploySettings["target-architecture"] = androidAbis.first(); } else { - applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toFileInfo().fileName(); + applicationBinary = buildSystem()->buildTarget(buildKey).targetFilePath.toFileInfo().fileName(); QJsonObject architectures; // Copy targets to android build folder diff --git a/src/plugins/android/androidbuildapkwidget.cpp b/src/plugins/android/androidbuildapkwidget.cpp index 984c3049dbd..9742d18222d 100644 --- a/src/plugins/android/androidbuildapkwidget.cpp +++ b/src/plugins/android/androidbuildapkwidget.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -329,8 +328,8 @@ QWidget *AndroidBuildApkWidget::createAdditionalLibrariesGroup() }); Target *target = m_step->target(); - RunConfiguration *rc = target->activeRunConfiguration(); - const ProjectNode *node = rc ? target->project()->findNodeForBuildKey(rc->buildKey()) : nullptr; + const QString buildKey = target->activeBuildKey(); + const ProjectNode *node = target->project()->findNodeForBuildKey(buildKey); group->setEnabled(node && !node->parseInProgress()); return group; diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index f3863ca998f..af0770598d3 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -222,7 +222,8 @@ bool AndroidDeployQtStep::init() m_useAndroiddeployqt = version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0); if (m_useAndroiddeployqt) { - const ProjectNode *node = target()->project()->findNodeForBuildKey(rc->buildKey()); + const QString buildKey = target()->activeBuildKey(); + const ProjectNode *node = target()->project()->findNodeForBuildKey(buildKey); if (!node) return false; m_apkPath = Utils::FilePath::fromString(node->data(Constants::AndroidApk).toString()); diff --git a/src/plugins/android/androidextralibrarylistmodel.cpp b/src/plugins/android/androidextralibrarylistmodel.cpp index 58c6c2c8a78..50400a49c1e 100644 --- a/src/plugins/android/androidextralibrarylistmodel.cpp +++ b/src/plugins/android/androidextralibrarylistmodel.cpp @@ -34,6 +34,8 @@ #include #include +#include + using namespace ProjectExplorer; namespace Android { @@ -49,6 +51,7 @@ AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Targ this, &AndroidExtraLibraryListModel::updateModel); connect(target, &Target::parsingFinished, this, &AndroidExtraLibraryListModel::updateModel); + // Causes target()->activeBuildKey() result to change. connect(target, &Target::activeRunConfigurationChanged, this, &AndroidExtraLibraryListModel::updateModel); } @@ -83,10 +86,8 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role) void AndroidExtraLibraryListModel::updateModel() { - RunConfiguration *rc = m_target->activeRunConfiguration(); - QTC_ASSERT(rc, return); - - const ProjectNode *node = m_target->project()->findNodeForBuildKey(rc->buildKey()); + const QString buildKey = m_target->activeBuildKey(); + const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); QTC_ASSERT(node, return); if (node->parseInProgress()) { @@ -111,10 +112,8 @@ void AndroidExtraLibraryListModel::updateModel() void AndroidExtraLibraryListModel::addEntries(const QStringList &list) { - RunConfiguration *rc = m_target->activeRunConfiguration(); - QTC_ASSERT(rc, return); - - const ProjectNode *node = m_target->project()->findNodeForBuildKey(rc->buildKey()); + const QString buildKey = m_target->activeBuildKey(); + const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); QTC_ASSERT(node, return); beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size()); @@ -153,9 +152,8 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list) endRemoveRows(); } - RunConfiguration *rc = m_target->activeRunConfiguration(); - QTC_ASSERT(rc, return); - const ProjectNode *node = m_target->project()->findNodeForBuildKey(rc->buildKey()); + const QString buildKey = m_target->activeBuildKey(); + const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); QTC_ASSERT(node, return); node->setData(Constants::AndroidExtraLibs, m_entries); } diff --git a/src/plugins/android/createandroidmanifestwizard.cpp b/src/plugins/android/createandroidmanifestwizard.cpp index ada75be278c..16547afdca2 100644 --- a/src/plugins/android/createandroidmanifestwizard.cpp +++ b/src/plugins/android/createandroidmanifestwizard.cpp @@ -108,15 +108,13 @@ ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard) fl->addRow(label); BuildSystem *buildSystem = wizard->buildSystem(); - QString currentBuildTarget; - if (RunConfiguration *rc = buildSystem->target()->activeRunConfiguration()) - currentBuildTarget = rc->buildKey(); + QString currentBuildKey = buildSystem->target()->activeBuildKey(); m_comboBox = new QComboBox(this); for (const BuildTargetInfo &bti : buildSystem->applicationTargets()) { const QString displayName = bti.buildKey; m_comboBox->addItem(displayName, QVariant(bti.buildKey)); // TODO something more? - if (bti.buildKey == currentBuildTarget) + if (bti.buildKey == currentBuildKey) m_comboBox->setCurrentIndex(m_comboBox->count() - 1); }