Do not store raw pointer to Library.

While it was "ok" to store raw pointer as, in our use case, the library
always live longer than object using it; it is not safe to store
raw pointer on object than may be deleted.

All classes storing a library now store a shared_ptr.
Functionr only using the library (as `HumanReadableNameMapper`) continue
to use a (const) reference.
This commit is contained in:
Matthieu Gautier
2022-10-06 12:00:27 +02:00
parent 5896691b31
commit 0bd5a5ec3b
13 changed files with 119 additions and 108 deletions

View File

@ -42,7 +42,7 @@ class OPDSDumper
{
public:
OPDSDumper() = default;
OPDSDumper(Library* library, NameMapper* NameMapper);
OPDSDumper(std::shared_ptr<Library> library, NameMapper* NameMapper);
~OPDSDumper();
/**
@ -110,7 +110,7 @@ class OPDSDumper
void setOpenSearchInfo(int totalResult, int startIndex, int count);
protected:
kiwix::Library* library;
std::shared_ptr<kiwix::Library> library;
kiwix::NameMapper* nameMapper;
std::string libraryId;
std::string rootLocation;