Fix SafeCountable and RefCountable copy/move logic
The safe and ref counts should not get copied around.
This commit is contained in:
parent
420c6aca23
commit
45a7496f54
|
@ -11,7 +11,7 @@ namespace Kakoune
|
|||
class AliasRegistry : public SafeCountable
|
||||
{
|
||||
public:
|
||||
AliasRegistry(AliasRegistry& parent) : m_parent(&parent) {}
|
||||
AliasRegistry(AliasRegistry& parent) : SafeCountable{}, m_parent(&parent) {}
|
||||
void add_alias(String alias, String command);
|
||||
void remove_alias(StringView alias);
|
||||
StringView operator[](StringView alias) const;
|
||||
|
|
|
@ -14,7 +14,7 @@ class Context;
|
|||
class HookManager : public SafeCountable
|
||||
{
|
||||
public:
|
||||
HookManager(HookManager& parent) : m_parent(&parent) {}
|
||||
HookManager(HookManager& parent) : SafeCountable{}, m_parent(&parent) {}
|
||||
|
||||
void add_hook(StringView hook_name, String group, Regex filter, String commands);
|
||||
void remove_hooks(StringView group);
|
||||
|
|
|
@ -8,8 +8,15 @@ namespace Kakoune
|
|||
|
||||
struct RefCountable
|
||||
{
|
||||
int refcount = 0;
|
||||
RefCountable() = default;
|
||||
RefCountable(const RefCountable&) {}
|
||||
RefCountable(RefCountable&&) {}
|
||||
virtual ~RefCountable() = default;
|
||||
|
||||
RefCountable& operator=(const RefCountable&) { return *this; }
|
||||
RefCountable& operator=(RefCountable&&) { return *this; }
|
||||
|
||||
int refcount = 0;
|
||||
};
|
||||
|
||||
struct RefCountablePolicy
|
||||
|
|
|
@ -24,7 +24,7 @@ class SafeCountable
|
|||
{
|
||||
public:
|
||||
#ifdef KAK_DEBUG
|
||||
SafeCountable() : m_count(0) {}
|
||||
SafeCountable() {}
|
||||
~SafeCountable()
|
||||
{
|
||||
kak_assert(m_count == 0);
|
||||
|
@ -33,6 +33,12 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
SafeCountable(const SafeCountable&) {}
|
||||
SafeCountable(SafeCountable&&) {}
|
||||
|
||||
SafeCountable& operator=(const SafeCountable& other) { return *this; }
|
||||
SafeCountable& operator=(SafeCountable&& other) { return *this; }
|
||||
|
||||
private:
|
||||
friend struct SafeCountablePolicy;
|
||||
#ifdef SAFE_PTR_TRACK_CALLSTACKS
|
||||
|
@ -45,7 +51,7 @@ private:
|
|||
|
||||
mutable Vector<Callstack> m_callstacks;
|
||||
#endif
|
||||
mutable int m_count;
|
||||
mutable int m_count = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user