Make the UpdatableNameMapper keep a shared_ptr.

Same as `Manager`, we want to be sure that `Library` actually exists
when we use it.
This commit is contained in:
Matthieu Gautier
2023-09-25 16:13:52 +02:00
parent 139b561253
commit efcbf6ef1e
3 changed files with 6 additions and 6 deletions

View File

@ -59,7 +59,7 @@ class HumanReadableNameMapper : public NameMapper {
class UpdatableNameMapper : public NameMapper {
typedef std::shared_ptr<NameMapper> NameMapperHandle;
public:
UpdatableNameMapper(Library& library, bool withAlias);
UpdatableNameMapper(std::shared_ptr<Library> library, bool withAlias);
virtual std::string getNameForId(const std::string& id) const;
virtual std::string getIdForName(const std::string& name) const;
@ -71,7 +71,7 @@ class UpdatableNameMapper : public NameMapper {
private:
mutable std::mutex mutex;
Library& library;
std::shared_ptr<Library> library;
NameMapperHandle nameMapper;
const bool withAlias;
};