From cfdce9be61a75f422ec1994d7fdf40893f90a300 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 2 Jun 2024 16:50:26 +0300 Subject: [PATCH] BAN: Mark RefPtr and WeakPtr helper destructors virtual Also fix a bug in WeakPtr::lock() which would assert false if the underlying weak link was not initialized --- BAN/include/BAN/RefPtr.h | 2 +- BAN/include/BAN/WeakPtr.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BAN/include/BAN/RefPtr.h b/BAN/include/BAN/RefPtr.h index ca881f3c..e76a5426 100644 --- a/BAN/include/BAN/RefPtr.h +++ b/BAN/include/BAN/RefPtr.h @@ -36,7 +36,7 @@ namespace BAN protected: RefCounted() = default; - ~RefCounted() { ASSERT(m_ref_count == 0); } + virtual ~RefCounted() { ASSERT(m_ref_count == 0); } private: mutable uint32_t m_ref_count = 1; diff --git a/BAN/include/BAN/WeakPtr.h b/BAN/include/BAN/WeakPtr.h index 7cb7063e..4c999731 100644 --- a/BAN/include/BAN/WeakPtr.h +++ b/BAN/include/BAN/WeakPtr.h @@ -34,7 +34,7 @@ namespace BAN class Weakable { public: - ~Weakable() + virtual ~Weakable() { if (m_link) m_link->invalidate(); @@ -82,7 +82,7 @@ namespace BAN RefPtr lock() { - if (m_link->valid()) + if (valid()) return m_link->lock(); return nullptr; }