diff --git a/src/doc/cel_data.cpp b/src/doc/cel_data.cpp index b83b83883..cb27ce074 100644 --- a/src/doc/cel_data.cpp +++ b/src/doc/cel_data.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2022 Igara Studio S.A. // Copyright (c) 2001-2016 David Capello // // This file is released under the terms of the MIT license. @@ -33,14 +34,13 @@ CelData::CelData(const CelData& celData) , m_image(celData.m_image) , m_opacity(celData.m_opacity) , m_bounds(celData.m_bounds) - , m_boundsF(celData.m_boundsF ? new gfx::RectF(*celData.m_boundsF): + , m_boundsF(celData.m_boundsF ? std::make_unique(*celData.m_boundsF): nullptr) { } CelData::~CelData() { - delete m_boundsF; } void CelData::setImage(const ImageRef& image) diff --git a/src/doc/cel_data.h b/src/doc/cel_data.h index b8ba83efd..d36430b4b 100644 --- a/src/doc/cel_data.h +++ b/src/doc/cel_data.h @@ -1,6 +1,6 @@ // Aseprite Document Library // Copyright (C) 2019-2022 Igara Studio S.A. -// Copyright (c) 2001-2016 David Capello +// Copyright (c) 2001-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -31,8 +31,14 @@ namespace doc { ImageRef imageRef() const { return m_image; } void setImage(const ImageRef& image); - void setPosition(const gfx::Point& pos) { m_bounds.setOrigin(pos); } - void setOpacity(int opacity) { m_opacity = opacity; } + + void setPosition(const gfx::Point& pos) { + m_bounds.setOrigin(pos); + } + + void setOpacity(int opacity) { + m_opacity = opacity; + } void setBounds(const gfx::Rect& bounds) { m_bounds = bounds; @@ -44,14 +50,14 @@ namespace doc { if (m_boundsF) *m_boundsF = boundsF; else - m_boundsF = new gfx::RectF(boundsF); + m_boundsF = std::make_unique(boundsF); m_bounds = gfx::Rect(boundsF); } const gfx::RectF& boundsF() const { if (!m_boundsF) - m_boundsF = new gfx::RectF(m_bounds); + m_boundsF = std::make_unique(m_bounds); return *m_boundsF; } @@ -71,7 +77,7 @@ namespace doc { // Special bounds for reference layers that can have subpixel // position. - mutable gfx::RectF* m_boundsF; + mutable std::unique_ptr m_boundsF; }; typedef std::shared_ptr CelDataRef;