summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-04-12 09:02:59 +1000
committerMaxime Coste <mawww@kakoune.org>2019-04-12 13:23:38 +1000
commitef1fd3acb95a58900d73a194ce8339b5301dfd0b (patch)
treeaeeb86a5c33a4985943cad6dd7686a49a967f74c /src
parentf732ea4efb13ced7055a7cc82d30c6cff0a558d3 (diff)
Prevent conversion to client on suspend from disconnecting other clients
clear the client manager in the to be converted process without sending exit messages as the forked server will still be there. Fixes #2847
Diffstat (limited to 'src')
-rw-r--r--src/buffer_manager.cc2
-rw-r--r--src/client_manager.cc13
-rw-r--r--src/client_manager.hh2
-rw-r--r--src/main.cc1
4 files changed, 12 insertions, 6 deletions
diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc
index d4e88b6c..30056525 100644
--- a/src/buffer_manager.cc
+++ b/src/buffer_manager.cc
@@ -21,7 +21,7 @@ BufferManager::~BufferManager()
// Make sure not clients exists
if (ClientManager::has_instance())
- ClientManager::instance().clear();
+ ClientManager::instance().clear(true);
}
Buffer* BufferManager::create_buffer(String name, Buffer::Flags flags,
diff --git a/src/client_manager.cc b/src/client_manager.cc
index 9dd32df5..ca32678f 100644
--- a/src/client_manager.cc
+++ b/src/client_manager.cc
@@ -14,13 +14,18 @@ namespace Kakoune
ClientManager::ClientManager() = default;
ClientManager::~ClientManager()
{
- clear();
+ clear(true);
}
-void ClientManager::clear()
+void ClientManager::clear(bool disconnect_clients)
{
- while (not m_clients.empty())
- remove_client(*m_clients.front(), true, 0);
+ if (disconnect_clients)
+ {
+ while (not m_clients.empty())
+ remove_client(*m_clients.front(), true, 0);
+ }
+ else
+ m_clients.clear();
m_client_trash.clear();
for (auto& window : m_free_windows)
diff --git a/src/client_manager.hh b/src/client_manager.hh
index 104d2124..7d92ed7e 100644
--- a/src/client_manager.hh
+++ b/src/client_manager.hh
@@ -27,7 +27,7 @@ public:
bool empty() const { return m_clients.empty(); }
size_t count() const { return m_clients.size(); }
- void clear();
+ void clear(bool exit);
void ensure_no_client_uses_buffer(Buffer& buffer);
diff --git a/src/main.cc b/src/main.cc
index 6b533003..d115ef2f 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -801,6 +801,7 @@ int run_server(StringView session, StringView server_init,
if (fork_server_to_background())
{
+ ClientManager::instance().clear(false);
String session = server.session();
server.close_session(false);
throw convert_to_client_mode{ std::move(session), std::move(client_name), std::move(buffer_name), std::move(selections) };