forked from qt-creator/qt-creator
ToolChain: Cache validity
Checking the validity of a toolchain can involve a call to a remote device. We cache the status now to speed up places that repeatedly check the validity like opening the Toolchain Settings Page Change-Id: I2b1d8aeba99fb9761d60d4710806bf4b767eaac9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -70,6 +70,7 @@ public:
|
|||||||
|
|
||||||
ToolChain::MacrosCache m_predefinedMacrosCache;
|
ToolChain::MacrosCache m_predefinedMacrosCache;
|
||||||
ToolChain::HeaderPathsCache m_headerPathsCache;
|
ToolChain::HeaderPathsCache m_headerPathsCache;
|
||||||
|
std::optional<bool> m_isValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -185,9 +186,10 @@ Abis ToolChain::supportedAbis() const
|
|||||||
|
|
||||||
bool ToolChain::isValid() const
|
bool ToolChain::isValid() const
|
||||||
{
|
{
|
||||||
if (compilerCommand().isEmpty())
|
if (!d->m_isValid.has_value())
|
||||||
return false;
|
d->m_isValid = !compilerCommand().isEmpty() && compilerCommand().isExecutableFile();
|
||||||
return compilerCommand().isExecutableFile();
|
|
||||||
|
return d->m_isValid.value_or(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ToolChain::includedFiles(const QStringList &flags, const QString &directory) const
|
QStringList ToolChain::includedFiles(const QStringList &flags, const QString &directory) const
|
||||||
@@ -315,6 +317,8 @@ FilePath ToolChain::compilerCommand() const
|
|||||||
|
|
||||||
void ToolChain::setCompilerCommand(const FilePath &command)
|
void ToolChain::setCompilerCommand(const FilePath &command)
|
||||||
{
|
{
|
||||||
|
d->m_isValid.reset();
|
||||||
|
|
||||||
if (command == d->m_compilerCommand)
|
if (command == d->m_compilerCommand)
|
||||||
return;
|
return;
|
||||||
d->m_compilerCommand = command;
|
d->m_compilerCommand = command;
|
||||||
@@ -379,6 +383,7 @@ bool ToolChain::fromMap(const QVariantMap &data)
|
|||||||
d->m_targetAbi = Abi::fromString(data.value(d->m_targetAbiKey).toString());
|
d->m_targetAbi = Abi::fromString(data.value(d->m_targetAbiKey).toString());
|
||||||
|
|
||||||
d->m_compilerCommand = FilePath::fromVariant(data.value(d->m_compilerCommandKey));
|
d->m_compilerCommand = FilePath::fromVariant(data.value(d->m_compilerCommandKey));
|
||||||
|
d->m_isValid.reset();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user