diff --git a/src/client_manager.cc b/src/client_manager.cc index 745a3f4b..946650f4 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -139,14 +139,22 @@ bool ClientManager::validate_client_name(const String& name) const return it == m_clients.end(); } -Client& ClientManager::get_client(const String& name) +Client* ClientManager::get_client_ifp(const String& name) { for (auto& client : m_clients) { if (client->context().name() == name) - return *client; + return client.get(); } - throw runtime_error("no client named: " + name); + return nullptr; +} + +Client& ClientManager::get_client(const String& name) +{ + Client* client = get_client_ifp(name); + if (not client) + throw runtime_error("no client named: " + name); + return *client; } void ClientManager::redraw_clients() const diff --git a/src/client_manager.hh b/src/client_manager.hh index 617b8ce0..2e6638e7 100644 --- a/src/client_manager.hh +++ b/src/client_manager.hh @@ -25,6 +25,7 @@ public: void redraw_clients() const; + Client* get_client_ifp(const String& name); Client& get_client(const String& name); bool validate_client_name(const String& name) const; void remove_client(Client& client);