From bbe4ea38e52df8dae89b53a05f2b2367ad733980 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 12 Feb 2024 19:38:59 -0500 Subject: [PATCH] Refactor Cube class to use smart pointers --- avogadro/core/cube.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/avogadro/core/cube.cpp b/avogadro/core/cube.cpp index e05ab01eb5..b902e4668c 100644 --- a/avogadro/core/cube.cpp +++ b/avogadro/core/cube.cpp @@ -7,21 +7,17 @@ #include "molecule.h" #include "mutex.h" +#include namespace Avogadro::Core { -Cube::Cube() - : m_data(0), m_min(0.0, 0.0, 0.0), m_max(0.0, 0.0, 0.0), - m_spacing(0.0, 0.0, 0.0), m_points(0, 0, 0), m_minValue(0.0), - m_maxValue(0.0), m_lock(new Mutex) -{ -} + Cube::Cube() + : m_data(0), m_min(0.0, 0.0, 0.0), m_max(0.0, 0.0, 0.0), + m_spacing(0.0, 0.0, 0.0), m_points(0, 0, 0), m_minValue(0.0), + m_maxValue(0.0), + m_lock(std::make_unique()) // Initializes m_lock with a new Mutex instance -Cube::~Cube() -{ - delete m_lock; - m_lock = nullptr; -} + Cube:: ~Cube() = default; // With unique_ptr, default destructor is fine. bool Cube::setLimits(const Vector3& min_, const Vector3& max_, const Vector3i& points)