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
|
class AliasRegistry : public SafeCountable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AliasRegistry(AliasRegistry& parent) : m_parent(&parent) {}
|
AliasRegistry(AliasRegistry& parent) : SafeCountable{}, m_parent(&parent) {}
|
||||||
void add_alias(String alias, String command);
|
void add_alias(String alias, String command);
|
||||||
void remove_alias(StringView alias);
|
void remove_alias(StringView alias);
|
||||||
StringView operator[](StringView alias) const;
|
StringView operator[](StringView alias) const;
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Context;
|
||||||
class HookManager : public SafeCountable
|
class HookManager : public SafeCountable
|
||||||
{
|
{
|
||||||
public:
|
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 add_hook(StringView hook_name, String group, Regex filter, String commands);
|
||||||
void remove_hooks(StringView group);
|
void remove_hooks(StringView group);
|
||||||
|
|
|
@ -8,8 +8,15 @@ namespace Kakoune
|
||||||
|
|
||||||
struct RefCountable
|
struct RefCountable
|
||||||
{
|
{
|
||||||
int refcount = 0;
|
RefCountable() = default;
|
||||||
|
RefCountable(const RefCountable&) {}
|
||||||
|
RefCountable(RefCountable&&) {}
|
||||||
virtual ~RefCountable() = default;
|
virtual ~RefCountable() = default;
|
||||||
|
|
||||||
|
RefCountable& operator=(const RefCountable&) { return *this; }
|
||||||
|
RefCountable& operator=(RefCountable&&) { return *this; }
|
||||||
|
|
||||||
|
int refcount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RefCountablePolicy
|
struct RefCountablePolicy
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SafeCountable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifdef KAK_DEBUG
|
#ifdef KAK_DEBUG
|
||||||
SafeCountable() : m_count(0) {}
|
SafeCountable() {}
|
||||||
~SafeCountable()
|
~SafeCountable()
|
||||||
{
|
{
|
||||||
kak_assert(m_count == 0);
|
kak_assert(m_count == 0);
|
||||||
|
@ -33,6 +33,12 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SafeCountable(const SafeCountable&) {}
|
||||||
|
SafeCountable(SafeCountable&&) {}
|
||||||
|
|
||||||
|
SafeCountable& operator=(const SafeCountable& other) { return *this; }
|
||||||
|
SafeCountable& operator=(SafeCountable&& other) { return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct SafeCountablePolicy;
|
friend struct SafeCountablePolicy;
|
||||||
#ifdef SAFE_PTR_TRACK_CALLSTACKS
|
#ifdef SAFE_PTR_TRACK_CALLSTACKS
|
||||||
|
@ -45,7 +51,7 @@ private:
|
||||||
|
|
||||||
mutable Vector<Callstack> m_callstacks;
|
mutable Vector<Callstack> m_callstacks;
|
||||||
#endif
|
#endif
|
||||||
mutable int m_count;
|
mutable int m_count = 0;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user