improve code

Change-Id: I06c7274c39f7e369d4cd9bed0c1ef77e4bc08b35
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Tim Jenssen
2019-10-25 19:48:14 +02:00
committed by Tim Jenssen
parent 8866153c2a
commit 0be200e44e
4 changed files with 10 additions and 17 deletions

View File

@@ -288,8 +288,8 @@ QJsonObject AndroidManager::deploymentSettings(const Target *target)
Utils::FilePath AndroidManager::dirPath(const ProjectExplorer::Target *target) Utils::FilePath AndroidManager::dirPath(const ProjectExplorer::Target *target)
{ {
if (target->activeBuildConfiguration()) if (auto *bc = target->activeBuildConfiguration())
return target->activeBuildConfiguration()->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY); return bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY);
return Utils::FilePath(); return Utils::FilePath();
} }

View File

@@ -315,15 +315,11 @@ static ::Utils::FilePath compilerPath(const CppTools::ProjectPart &projectPart)
static ::Utils::FilePath buildDirectory(const ProjectExplorer::Project &project) static ::Utils::FilePath buildDirectory(const ProjectExplorer::Project &project)
{ {
ProjectExplorer::Target *target = project.activeTarget(); if (auto *target = project.activeTarget()) {
if (!target) if (auto *bc = target->activeBuildConfiguration())
return ::Utils::FilePath(); return bc->buildDirectory();
}
ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration(); return {};
if (!buildConfig)
return ::Utils::FilePath();
return buildConfig->buildDirectory();
} }
static QStringList projectPartArguments(const ProjectPart &projectPart) static QStringList projectPartArguments(const ProjectPart &projectPart)

View File

@@ -495,7 +495,7 @@ void ClangToolRunWorker::finalize()
QString msg = tr("%1: Not all files could be analyzed.").arg(toolName); QString msg = tr("%1: Not all files could be analyzed.").arg(toolName);
TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID);
Target *target = runControl()->target(); Target *target = runControl()->target();
if (target && !target->activeBuildConfiguration()->buildDirectory().exists() if (target && target->activeBuildConfiguration() && !target->activeBuildConfiguration()->buildDirectory().exists()
&& !m_runSettings.buildBeforeAnalysis()) { && !m_runSettings.buildBeforeAnalysis()) {
msg = tr("%1: You might need to build the project to generate or update source " msg = tr("%1: You might need to build the project to generate or update source "
"files. To build automatically, enable \"Build the project before starting " "files. To build automatically, enable \"Build the project before starting "

View File

@@ -106,11 +106,8 @@ void PerfLoadDialog::chooseDefaults()
ui->kitChooser->setCurrentKitId(target->kit()->id()); ui->kitChooser->setCurrentKitId(target->kit()->id());
ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration(); if (auto *bc = target->activeBuildConfiguration())
if (!buildConfig) ui->executableDirLineEdit->setText(bc->buildDirectory().toString());
return;
ui->executableDirLineEdit->setText(buildConfig->buildDirectory().toString());
} }
} // namespace Internal } // namespace Internal