Commit a5e2b4b1 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Check for valid active target

The active target might be 0 if e.g. there are not kits and a project is
imported.

Task-number: QTCREATORBUG-13730
Change-Id: I48ade507fefc555d1d3f8230ba82c00270fa457b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent b158b7e5
......@@ -37,6 +37,8 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <QSet>
#include <QTextStream>
......@@ -457,12 +459,16 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources,
CppTools::ProjectPart::Ptr part(m_templatePart->copy());
part->displayName = partName;
Kit *k = part->project->activeTarget()->kit();
if (ToolChain *tc = ToolChainKitInformation::toolChain(k))
part->evaluateToolchain(tc,
languageVersion >= ProjectPart::CXX98 ? m_cxxFlags
: m_cFlags,
SysRootKitInformation::sysRoot(k));
QTC_ASSERT(part->project, return);
if (ProjectExplorer::Target *activeTarget = part->project->activeTarget()) {
if (Kit *kit = activeTarget->kit()) {
if (ToolChain *toolChain = ToolChainKitInformation::toolChain(kit)) {
const QStringList flags = languageVersion >= ProjectPart::CXX98 ? m_cxxFlags
: m_cFlags;
part->evaluateToolchain(toolChain, flags, SysRootKitInformation::sysRoot(kit));
}
}
}
part->languageExtensions |= languageExtensions;
......
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