diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-11-14 15:50:00 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-11-14 16:17:12 +0000 |
commit | cca33e2e2695773890660002608ec59330e118d1 (patch) | |
tree | 7f4c4fdbb071939656540e3646055192336e0e42 /src/plugins/cmakeprojectmanager/cmaketool.cpp | |
parent | 631efb8611bdebdbcaf3c07beca9b5aaed933069 (diff) |
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>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmaketool.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmaketool.cpp | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 361e0acd889..c1623bcebf2 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -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,18 +382,16 @@ 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; - } - - if (type == QueryType::GENERATORS) { - fetchGeneratorsFromHelp(); - } else if (type == QueryType::SERVER_MODE) { - // Nothing to do... - } else if (type == QueryType::VERSION) { - fetchVersionFromVersionOutput(); } else { - QTC_ASSERT(false, return ); + if (type == QueryType::GENERATORS) { + fetchGeneratorsFromHelp(); + } else if (type == QueryType::SERVER_MODE) { + // Nothing to do... + } else if (type == QueryType::VERSION) { + fetchVersionFromVersionOutput(); + } else { + QTC_ASSERT(false, return ); + } } } @@ -495,9 +489,11 @@ QStringList CMakeTool::parseVariableOutput(const QString &output) void CMakeTool::fetchGeneratorsFromHelp() const { Utils::SynchronousProcessResponse response = run({"--help"}); - if (response.result != Utils::SynchronousProcessResponse::Finished) - return; - parseGeneratorsFromHelp(response.stdOut().split('\n')); + m_introspection->m_didRun = m_introspection->m_didRun + && response.result == Utils::SynchronousProcessResponse::Finished; + + if (response.result == Utils::SynchronousProcessResponse::Finished) + parseGeneratorsFromHelp(response.stdOut().split('\n')); } void CMakeTool::parseGeneratorsFromHelp(const QStringList &lines) const @@ -550,10 +546,12 @@ void CMakeTool::parseGeneratorsFromHelp(const QStringList &lines) const void CMakeTool::fetchVersionFromVersionOutput() const { Utils::SynchronousProcessResponse response = run({"--version"}); - if (response.result != Utils::SynchronousProcessResponse::Finished) - return; - parseVersionFormVersionOutput(response.stdOut().split('\n')); + m_introspection->m_didRun = m_introspection->m_didRun + && response.result == Utils::SynchronousProcessResponse::Finished; + + if (response.result == Utils::SynchronousProcessResponse::Finished) + parseVersionFormVersionOutput(response.stdOut().split('\n')); } void CMakeTool::parseVersionFormVersionOutput(const QStringList &lines) const @@ -574,11 +572,10 @@ 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"}); - parseFromCapabilities(response.stdOut()); + if (response.result == Utils::SynchronousProcessResponse::Finished) + parseFromCapabilities(response.stdOut()); } static int getVersion(const QVariantMap &obj, const QString value) |