diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/manager/SaveManager.cpp | 7 | ||||
-rw-r--r-- | src/crepe/manager/SaveManager.h | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/crepe/manager/SaveManager.cpp b/src/crepe/manager/SaveManager.cpp index 292e8fd..39b92d4 100644 --- a/src/crepe/manager/SaveManager.cpp +++ b/src/crepe/manager/SaveManager.cpp @@ -14,9 +14,12 @@ SaveManager::SaveManager(Mediator & mediator) : Manager(mediator) { DB & SaveManager::get_db() { if (this->db == nullptr) { Config & cfg = Config::get_instance(); - this->db = make_unique<DB>(cfg.savemgr.location); + this->db = { + new DB(cfg.savemgr.location), + [](void * db){ delete static_cast<DB *>(db); } + }; } - return *this->db; + return *static_cast<DB *>(this->db.get()); } template <> diff --git a/src/crepe/manager/SaveManager.h b/src/crepe/manager/SaveManager.h index 1b55a22..27e625c 100644 --- a/src/crepe/manager/SaveManager.h +++ b/src/crepe/manager/SaveManager.h @@ -1,6 +1,7 @@ #pragma once #include <memory> +#include <functional> #include "../ValueBroker.h" @@ -96,7 +97,7 @@ protected: virtual DB & get_db(); private: //! Database - std::unique_ptr<DB> db = nullptr; + std::unique_ptr<void, std::function<void(void*)>> db = nullptr; }; } // namespace crepe |