forked from qt-creator/qt-creator
KitInformation: Improve robustness to nullptr passed as kit
All the KitInformation methods need to gracefully handle a kit that is a nullptr. Ensure this is indeed the case. This might fix the actual trigger for QTCREATORBUG-19469. Change-Id: Id78ac8a26c1be908f41a425ff1935b86888e4b8b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -86,7 +86,7 @@ Core::Id CMakeKitInformation::id()
|
||||
CMakeTool *CMakeKitInformation::cmakeTool(const Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
const QVariant id = k->value(TOOL_ID);
|
||||
return CMakeToolManager::findById(Core::Id::fromSetting(id));
|
||||
@@ -142,11 +142,13 @@ KitInformation::ItemList CMakeKitInformation::toUserOutput(const Kit *k) const
|
||||
|
||||
KitConfigWidget *CMakeKitInformation::createConfigWidget(Kit *k) const
|
||||
{
|
||||
QTC_ASSERT(k, return nullptr);
|
||||
return new Internal::CMakeKitConfigWidget(k, this);
|
||||
}
|
||||
|
||||
void CMakeKitInformation::addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const
|
||||
{
|
||||
QTC_ASSERT(k, return);
|
||||
expander->registerFileVariables("CMake:Executable", tr("Path to the cmake executable"),
|
||||
[k]() -> QString {
|
||||
CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
|
||||
@@ -304,6 +306,8 @@ QStringList CMakeGeneratorKitInformation::generatorArguments(const Kit *k)
|
||||
|
||||
QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const
|
||||
{
|
||||
QTC_ASSERT(k, return QVariant());
|
||||
|
||||
CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
|
||||
if (!tool)
|
||||
return QVariant();
|
||||
@@ -426,6 +430,8 @@ void CMakeGeneratorKitInformation::fix(Kit *k)
|
||||
|
||||
void CMakeGeneratorKitInformation::upgrade(Kit *k)
|
||||
{
|
||||
QTC_ASSERT(k, return);
|
||||
|
||||
const QVariant value = k->value(GENERATOR_ID);
|
||||
if (value.type() != QVariant::Map) {
|
||||
GeneratorInfo info;
|
||||
@@ -545,6 +551,8 @@ QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
|
||||
|
||||
QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
|
||||
{
|
||||
QTC_ASSERT(k, return QList<Task>());
|
||||
|
||||
const QtSupport::BaseQtVersion *const version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
const ToolChain *const tcC = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
||||
const ToolChain *const tcCxx = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
@@ -659,7 +667,7 @@ KitInformation::ItemList CMakeConfigurationKitInformation::toUserOutput(const Ki
|
||||
KitConfigWidget *CMakeConfigurationKitInformation::createConfigWidget(Kit *k) const
|
||||
{
|
||||
if (!k)
|
||||
return 0;
|
||||
return nullptr;
|
||||
return new Internal::CMakeConfigurationKitConfigWidget(k, this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user