From 82512db44a29fcc8dcf01dbdcad0538187cb7bf8c5d4bf4c34e8b9e6aba0fb95 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 10 Aug 2025 17:27:52 -0400 Subject: [PATCH] Start to permeate more ownership. --- dw/fltkimgbuf.hh | 4 +--- dw/fltkplatform.cc | 7 ++++--- dw/fltkplatform.hh | 4 ++-- dw/layout.hh | 4 ++-- dw/platform.hh | 6 ++++-- src/imgbuf.cc | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dw/fltkimgbuf.hh b/dw/fltkimgbuf.hh index 5c2be4c..2ea3152 100644 --- a/dw/fltkimgbuf.hh +++ b/dw/fltkimgbuf.hh @@ -49,10 +49,8 @@ private: int isRoot() { return (root == NULL); } void detachScaledBuf (FltkImgbuf *scaledBuf); -protected: - ~FltkImgbuf (); - public: + ~FltkImgbuf (); FltkImgbuf (Type type, int width, int height, double gamma); static void freeall (); diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index af713db..ab14ef2 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -692,10 +692,11 @@ void FltkPlatform::copySelection(const char *text) Fl::copy(text, strlen(text), 0); } -core::Imgbuf *FltkPlatform::createImgbuf (core::Imgbuf::Type type, - int width, int height, double gamma) +std::unique_ptr< core::Imgbuf > +FltkPlatform::createImgbuf( core::Imgbuf::Type type, + int width, int height, double gamma) { - return new FltkImgbuf (type, width, height, gamma); + return std::make_unique< FltkImgbuf >( type, width, height, gamma ); } core::ui::ResourceFactory *FltkPlatform::getResourceFactory () diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 7b984b2..92ac540 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -171,8 +171,8 @@ public: core::style::Tooltip *createTooltip (const char *text); void cancelTooltip(); - core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height, - double gamma); + std::unique_ptr< core::Imgbuf > createImgbuf( core::Imgbuf::Type type, int width, int height, + double gamma ); void copySelection(const char *text); diff --git a/dw/layout.hh b/dw/layout.hh index ef15d59..04d169b 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -414,8 +414,8 @@ public: return platform->cancelTooltip (); } - inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height, - double gamma) + inline std::unique_ptr< Imgbuf > + createImgbuf( Imgbuf::Type type, int width, int height, double gamma ) { return platform->createImgbuf (type, width, height, gamma); } diff --git a/dw/platform.hh b/dw/platform.hh index 093508d..2748aca 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -1,6 +1,8 @@ #ifndef __DW_PLATFORM_HH__ #define __DW_PLATFORM_HH__ +#include + #ifndef __INCLUDED_FROM_DW_CORE_HH__ # error Do not include this file directly, use "core.hh" instead. #endif @@ -152,8 +154,8 @@ public: * * "gamma" is the value by which the image data is gamma-encoded. */ - virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height, - double gamma) = 0; + virtual std::unique_ptr< Imgbuf > createImgbuf( Imgbuf::Type type, int width, int height, + double gamma )= 0; /** * \brief Copy selected text (0-terminated). diff --git a/src/imgbuf.cc b/src/imgbuf.cc index 852fb4b..edb6cf6 100644 --- a/src/imgbuf.cc +++ b/src/imgbuf.cc @@ -104,7 +104,7 @@ void *a_Imgbuf_new(void *layout, int img_type, uint_t width, uint_t height, } return (void*)((Layout*)layout)->createImgbuf(Imgbuf::RGB, width, height, - gamma); + gamma).release(); } /**