Skip to content

Commit

Permalink
Refactor Cube class to use smart pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlindbergh committed Feb 13, 2024
1 parent 509ca48 commit bbe4ea3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions avogadro/core/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@

#include "molecule.h"
#include "mutex.h"
#include <memory>

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<Mutex>()) // 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)
Expand Down

0 comments on commit bbe4ea3

Please sign in to comment.