forked from qt-creator/qt-creator
CMake: Do not make the CMake tool invalid on timeout
Do no mark the CMake tool as invalid when it times out when fetching auto-completion information. This happens the first time a CMakeLists.txt file is edited in Creator. Also increase the timeout so that there is less of a chance to trigger have the information retrival time out -- which breaks auto-completion of cmake variables, etc. in the CMakeLists.txt editor. Closes: QTCREATORBUG-18530 Change-Id: I914377a6ece90c6f78ea5eb007da8fbe07785563 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -105,7 +105,7 @@ class IntrospectionData
|
||||
{
|
||||
public:
|
||||
bool m_didAttemptToRun = false;
|
||||
bool m_didRun = false;
|
||||
bool m_didRun = true;
|
||||
bool m_hasServerMode = false;
|
||||
|
||||
bool m_queriedServerMode = false;
|
||||
@@ -200,26 +200,17 @@ bool CMakeTool::isValid() const
|
||||
return m_introspection->m_didRun;
|
||||
}
|
||||
|
||||
Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, bool mayFail) const
|
||||
Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, int timeoutS) const
|
||||
{
|
||||
if (m_introspection->m_didAttemptToRun && !m_introspection->m_didRun) {
|
||||
Utils::SynchronousProcessResponse response;
|
||||
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
||||
return response;
|
||||
}
|
||||
|
||||
Utils::SynchronousProcess cmake;
|
||||
cmake.setTimeoutS(1);
|
||||
cmake.setTimeoutS(timeoutS);
|
||||
cmake.setFlags(Utils::SynchronousProcess::UnixTerminalDisabled);
|
||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||
Utils::Environment::setupEnglishOutput(&env);
|
||||
cmake.setProcessEnvironment(env.toProcessEnvironment());
|
||||
cmake.setTimeOutMessageBoxEnabled(false);
|
||||
|
||||
Utils::SynchronousProcessResponse response = cmake.runBlocking({cmakeExecutable(), args});
|
||||
m_introspection->m_didAttemptToRun = true;
|
||||
m_introspection->m_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished);
|
||||
return response;
|
||||
return cmake.runBlocking({cmakeExecutable(), args});
|
||||
}
|
||||
|
||||
QVariantMap CMakeTool::toMap() const
|
||||
@@ -280,21 +271,21 @@ QList<CMakeTool::Generator> CMakeTool::supportedGenerators() const
|
||||
|
||||
TextEditor::Keywords CMakeTool::keywords()
|
||||
{
|
||||
if (m_introspection->m_functions.isEmpty()) {
|
||||
if (m_introspection->m_functions.isEmpty() && m_introspection->m_didRun) {
|
||||
Utils::SynchronousProcessResponse response;
|
||||
response = run({"--help-command-list"});
|
||||
response = run({"--help-command-list"}, 5);
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
m_introspection->m_functions = response.stdOut().split('\n');
|
||||
|
||||
response = run({"--help-commands"});
|
||||
response = run({"--help-commands"}, 5);
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
parseFunctionDetailsOutput(response.stdOut());
|
||||
|
||||
response = run({"--help-property-list"});
|
||||
response = run({"--help-property-list"}, 5);
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
m_introspection->m_variables = parseVariableOutput(response.stdOut());
|
||||
|
||||
response = run({"--help-variable-list"});
|
||||
response = run({"--help-variable-list"}, 5);
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
m_introspection->m_variables.append(parseVariableOutput(response.stdOut()));
|
||||
m_introspection->m_variables = Utils::filteredUnique(m_introspection->m_variables);
|
||||
@@ -377,6 +368,11 @@ CMakeTool::ReaderType CMakeTool::readerType() const
|
||||
|
||||
void CMakeTool::readInformation(CMakeTool::QueryType type) const
|
||||
{
|
||||
if (!m_introspection->m_didRun && m_introspection->m_didAttemptToRun)
|
||||
return;
|
||||
|
||||
m_introspection->m_didAttemptToRun = true;
|
||||
|
||||
if ((type == QueryType::GENERATORS && !m_introspection->m_generators.isEmpty())
|
||||
|| (type == QueryType::SERVER_MODE && m_introspection->m_queriedServerMode)
|
||||
|| (type == QueryType::VERSION && !m_introspection->m_version.fullVersion.isEmpty()))
|
||||
@@ -386,10 +382,7 @@ void CMakeTool::readInformation(CMakeTool::QueryType type) const
|
||||
fetchFromCapabilities();
|
||||
m_introspection->m_triedCapabilities = true;
|
||||
m_introspection->m_queriedServerMode = true; // Got added after "-E capabilities" support!
|
||||
if (type == QueryType::GENERATORS && !m_introspection->m_generators.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (type == QueryType::GENERATORS) {
|
||||
fetchGeneratorsFromHelp();
|
||||
} else if (type == QueryType::SERVER_MODE) {
|
||||
@@ -400,6 +393,7 @@ void CMakeTool::readInformation(CMakeTool::QueryType type) const
|
||||
QTC_ASSERT(false, return );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static QStringList parseDefinition(const QString &definition)
|
||||
{
|
||||
@@ -495,8 +489,10 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
|
||||
void CMakeTool::fetchGeneratorsFromHelp() const
|
||||
{
|
||||
Utils::SynchronousProcessResponse response = run({"--help"});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return;
|
||||
m_introspection->m_didRun = m_introspection->m_didRun
|
||||
&& response.result == Utils::SynchronousProcessResponse::Finished;
|
||||
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
parseGeneratorsFromHelp(response.stdOut().split('\n'));
|
||||
}
|
||||
|
||||
@@ -550,9 +546,11 @@ void CMakeTool::parseGeneratorsFromHelp(const QStringList &lines) const
|
||||
void CMakeTool::fetchVersionFromVersionOutput() const
|
||||
{
|
||||
Utils::SynchronousProcessResponse response = run({"--version"});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return;
|
||||
|
||||
m_introspection->m_didRun = m_introspection->m_didRun
|
||||
&& response.result == Utils::SynchronousProcessResponse::Finished;
|
||||
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
parseVersionFormVersionOutput(response.stdOut().split('\n'));
|
||||
}
|
||||
|
||||
@@ -574,10 +572,9 @@ void CMakeTool::parseVersionFormVersionOutput(const QStringList &lines) const
|
||||
|
||||
void CMakeTool::fetchFromCapabilities() const
|
||||
{
|
||||
Utils::SynchronousProcessResponse response = run({"-E", "capabilities"}, true);
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return;
|
||||
Utils::SynchronousProcessResponse response = run({"-E", "capabilities"});
|
||||
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished)
|
||||
parseFromCapabilities(response.stdOut());
|
||||
}
|
||||
|
||||
|
@@ -122,7 +122,7 @@ private:
|
||||
};
|
||||
void readInformation(QueryType type) const;
|
||||
|
||||
Utils::SynchronousProcessResponse run(const QStringList &args, bool mayFail = false) const;
|
||||
Utils::SynchronousProcessResponse run(const QStringList &args, int timeoutS = 1) const;
|
||||
void parseFunctionDetailsOutput(const QString &output);
|
||||
QStringList parseVariableOutput(const QString &output);
|
||||
|
||||
|
Reference in New Issue
Block a user