Make HookManager safe counted

This commit is contained in:
Maxime Coste 2016-05-15 10:37:42 +01:00
parent baf219ee2f
commit 8c6849bb04

View File

@ -3,6 +3,7 @@
#include "id_map.hh" #include "id_map.hh"
#include "completion.hh" #include "completion.hh"
#include "safe_ptr.hh"
namespace Kakoune namespace Kakoune
{ {
@ -10,7 +11,7 @@ namespace Kakoune
class Context; class Context;
using HookFunc = std::function<void (StringView, Context&)>; using HookFunc = std::function<void (StringView, Context&)>;
class HookManager class HookManager : public SafeCountable
{ {
public: public:
HookManager(HookManager& parent) : m_parent(&parent) {} HookManager(HookManager& parent) : m_parent(&parent) {}
@ -27,7 +28,7 @@ private:
// the only one allowed to construct a root hook manager // the only one allowed to construct a root hook manager
friend class Scope; friend class Scope;
HookManager* m_parent; SafePtr<HookManager> m_parent;
IdMap<IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook; IdMap<IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook;
}; };