qtcreator-languageclient2.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From bd00cc8bf8742a0c344266879cef680093bfdbf0 Mon Sep 17 00:00:00 2001
  2. From: Christian Kandeler <christian.kandeler@qt.io>
  3. Date: Wed, 10 Aug 2022 15:37:31 +0200
  4. Subject: LanguageClient: Introduce timeout for restart counter
  5. While it makes sense to stop trying to restart a continuously crashing
  6. server, the restart counter should be reset regularly, as it's not
  7. critical if the server restarts "once in a while" during a longer
  8. programming session.
  9. Change-Id: Ia2efca28ae4a4dba72da947d9eb776e3909d0cb3
  10. Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
  11. Reviewed-by: David Schulz <david.schulz@qt.io>
  12. ---
  13. src/plugins/languageclient/client.cpp | 14 ++++++++++++--
  14. 1 file changed, 12 insertions(+), 2 deletions(-)
  15. diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp
  16. index 78a2a259c9..c624b13979 100644
  17. --- a/src/plugins/languageclient/client.cpp
  18. +++ b/src/plugins/languageclient/client.cpp
  19. @@ -197,6 +197,11 @@ public:
  20. connect(&m_shutdownTimer, &QTimer::timeout, this, [this] {
  21. LanguageClientManager::deleteClient(q);
  22. });
  23. +
  24. + m_restartCountResetTimer.setSingleShot(true);
  25. + m_restartCountResetTimer.setInterval(5 * 60 * 1000);
  26. + connect(&m_restartCountResetTimer, &QTimer::timeout,
  27. + this, [this] { m_restartsLeft = MaxRestarts; });
  28. }
  29. ~ClientPrivate()
  30. @@ -307,7 +312,9 @@ public:
  31. AssistProviders m_clientProviders;
  32. QMap<TextEditor::TextDocument *, AssistProviders> m_resetAssistProvider;
  33. QHash<TextEditor::TextEditorWidget *, LanguageServerProtocol::MessageId> m_highlightRequests;
  34. - int m_restartsLeft = 5;
  35. + static const int MaxRestarts = 2;
  36. + int m_restartsLeft = MaxRestarts;
  37. + QTimer m_restartCountResetTimer;
  38. InterfaceController *m_clientInterface = nullptr;
  39. DiagnosticManager *m_diagnosticManager = nullptr;
  40. DocumentSymbolCache m_documentSymbolCache;
  41. @@ -1511,8 +1518,11 @@ bool Client::reset()
  42. bool ClientPrivate::reset()
  43. {
  44. - if (!m_restartsLeft)
  45. + if (!m_restartsLeft) {
  46. + m_restartCountResetTimer.stop();
  47. return false;
  48. + }
  49. + m_restartCountResetTimer.start();
  50. --m_restartsLeft;
  51. m_state = Client::Uninitialized;
  52. m_responseHandlers.clear();
  53. --
  54. cgit v1.2.1