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 @@ ...@@ -37,6 +37,8 @@
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <QSet> #include <QSet>
#include <QTextStream> #include <QTextStream>
...@@ -457,12 +459,16 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources, ...@@ -457,12 +459,16 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources,
CppTools::ProjectPart::Ptr part(m_templatePart->copy()); CppTools::ProjectPart::Ptr part(m_templatePart->copy());
part->displayName = partName; part->displayName = partName;
Kit *k = part->project->activeTarget()->kit(); QTC_ASSERT(part->project, return);
if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) if (ProjectExplorer::Target *activeTarget = part->project->activeTarget()) {
part->evaluateToolchain(tc, if (Kit *kit = activeTarget->kit()) {
languageVersion >= ProjectPart::CXX98 ? m_cxxFlags if (ToolChain *toolChain = ToolChainKitInformation::toolChain(kit)) {
: m_cFlags, const QStringList flags = languageVersion >= ProjectPart::CXX98 ? m_cxxFlags
SysRootKitInformation::sysRoot(k)); : m_cFlags;
part->evaluateToolchain(toolChain, flags, SysRootKitInformation::sysRoot(kit));
}
}
}
part->languageExtensions |= languageExtensions; 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