Commit 208851d3 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: replace shutdown inner event loop by plain sleep

See issue #7
parent e2982ab0
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonParseError> #include <QJsonParseError>
#include <QRegularExpression> #include <QRegularExpression>
#include <QThread>
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
...@@ -255,11 +256,18 @@ public: ...@@ -255,11 +256,18 @@ public:
QTimer t; QTimer t;
connect(&t, &QTimer::timeout, &q, &QEventLoop::quit); connect(&t, &QTimer::timeout, &q, &QEventLoop::quit);
auto run = [&q, &t](int ms) { /* some msleep are used below which is somewhat BAD as it blocks/hangs
t.setSingleShot(true); * the mainloop, however there is not much alternative:
t.start(ms); * + running an inner mainloop leads to event processing,
q.exec(); * which could trigger an unexpected sequence of 'events'
}; * such as (re)loading plugin that is currently still unloading
* (consider scenario of fast-clicking enable/disable of LSP plugin)
* + could reduce or forego the sleep, but that increases chances
* on an unclean shutdown of LSP server, which may or may not
* be able to handle that properly (so let's try and be a polite
* client and try to avoid that to some degree)
* So we are left with a minor sleep compromise ...
*/
int count = 0; int count = 0;
for (const auto &el : m_servers) { for (const auto &el : m_servers) {
...@@ -282,7 +290,7 @@ public: ...@@ -282,7 +290,7 @@ public:
} }
} }
} }
run(500); QThread::msleep(500);
// stage 2 and 3 // stage 2 and 3
count = 0; count = 0;
...@@ -295,7 +303,7 @@ public: ...@@ -295,7 +303,7 @@ public:
s->stop(count == 0 ? 1 : -1, count == 0 ? -1 : 1); s->stop(count == 0 ? 1 : -1, count == 0 ? -1 : 1);
} }
} }
run(100); QThread::msleep(100);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment