summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-08-04 11:38:04 +0700
committerMaxime Coste <mawww@kakoune.org>2017-08-04 11:38:04 +0700
commit45a7496f545bf7b10940bc55c27ddf018a1ffd17 (patch)
tree4f4ba6434083d518f5217f27006d15adeb4fa739 /src
parent420c6aca233e79249ffc8513347f73978eb0ecdc (diff)
Fix SafeCountable and RefCountable copy/move logic
The safe and ref counts should not get copied around.
Diffstat (limited to 'src')
-rw-r--r--src/alias_registry.hh2
-rw-r--r--src/hook_manager.hh2
-rw-r--r--src/ref_ptr.hh9
-rw-r--r--src/safe_ptr.hh10
4 files changed, 18 insertions, 5 deletions
diff --git a/src/alias_registry.hh b/src/alias_registry.hh
index 8fa277c3..49571c1e 100644
--- a/src/alias_registry.hh
+++ b/src/alias_registry.hh
@@ -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;
diff --git a/src/hook_manager.hh b/src/hook_manager.hh
index 9cfa4a9b..66baecf3 100644
--- a/src/hook_manager.hh
+++ b/src/hook_manager.hh
@@ -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);
diff --git a/src/ref_ptr.hh b/src/ref_ptr.hh
index 5711ced2..0dbc0be7 100644
--- a/src/ref_ptr.hh
+++ b/src/ref_ptr.hh
@@ -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
diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh
index 4d83a46d..38d58046 100644
--- a/src/safe_ptr.hh
+++ b/src/safe_ptr.hh
@@ -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
};