forked from qt-creator/qt-creator
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: Tobias Hunger <tobias.hunger@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -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,
|
|||||||
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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user