Let client manager handle deleting client
This commit is contained in:
parent
713fa9d406
commit
533079c389
|
@ -25,6 +25,7 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||||
}
|
}
|
||||||
catch (Kakoune::client_removed&)
|
catch (Kakoune::client_removed&)
|
||||||
{
|
{
|
||||||
|
ClientManager::instance().remove_client_by_context(*context);
|
||||||
EventManager::instance().unwatch(fd);
|
EventManager::instance().unwatch(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ class ClientManager : public Singleton<ClientManager>
|
||||||
public:
|
public:
|
||||||
void create_client(std::unique_ptr<UserInterface>&& ui,
|
void create_client(std::unique_ptr<UserInterface>&& ui,
|
||||||
Buffer& buffer, int event_fd);
|
Buffer& buffer, int event_fd);
|
||||||
void remove_client_by_context(Context& context);
|
|
||||||
|
|
||||||
bool empty() const { return m_clients.empty(); }
|
bool empty() const { return m_clients.empty(); }
|
||||||
size_t count() const { return m_clients.size(); }
|
size_t count() const { return m_clients.size(); }
|
||||||
|
@ -24,6 +23,8 @@ public:
|
||||||
|
|
||||||
void redraw_clients() const;
|
void redraw_clients() const;
|
||||||
private:
|
private:
|
||||||
|
void remove_client_by_context(Context& context);
|
||||||
|
|
||||||
struct Client
|
struct Client
|
||||||
{
|
{
|
||||||
Client(std::unique_ptr<UserInterface>&& ui, Window& window)
|
Client(std::unique_ptr<UserInterface>&& ui, Window& window)
|
||||||
|
|
|
@ -363,7 +363,7 @@ void quit(const CommandParameters& params, Context& context)
|
||||||
throw runtime_error(message);
|
throw runtime_error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClientManager::instance().remove_client_by_context(context);
|
// unwind back to this client event handler.
|
||||||
throw client_removed{};
|
throw client_removed{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user