From 918a283748eda8234e97bb832c93437eb17cd780579c44de0916a224c81712cd Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 19 Apr 2025 01:02:59 -0400 Subject: [PATCH] Ownership of Platform in part of the code. --- dw/layout.cc | 5 ++--- dw/layout.hh | 4 ++-- src/uicmd.cc | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dw/layout.cc b/dw/layout.cc index a5b1758..2d6474c 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -257,7 +257,7 @@ Layout::Anchor::~Anchor () Layout::Layout (std::unique_ptr< Platform > platform, bool limit) { - this->platform = platform.release(); + this->platform = std::move( platform ); view = NULL; topLevel = NULL; widgetAtPoint = NULL; @@ -292,7 +292,7 @@ Layout::Layout (std::unique_ptr< Platform > platform, bool limit) DBG_OBJ_ASSOC_CHILD (&findtextState); DBG_OBJ_ASSOC_CHILD (&selectionState); - platform->setLayout (this); + this->platform->setLayout (this); selectionState.setLayout(this); @@ -329,7 +329,6 @@ Layout::~Layout () topLevel.reset(); } - delete platform; delete view; delete textZone; diff --git a/dw/layout.hh b/dw/layout.hh index 2c4be30..ef15d59 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -157,7 +157,7 @@ private: ~Anchor (); }; - Platform *platform; + std::unique_ptr< Platform > platform; View *view; std::unique_ptr< Widget > topLevel; Widget *widgetAtPoint; @@ -349,7 +349,7 @@ public: inline Platform *getPlatform () { - return platform; + return platform.get(); } /* delegated */ diff --git a/src/uicmd.cc b/src/uicmd.cc index 9b7d212..2dd886f 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -631,8 +631,8 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) UI *new_ui = tabs->add_new_tab(old_ui, focus); // Now create the Dw render layout and viewport - FltkPlatform *platform = new FltkPlatform (); - Layout *layout = new Layout (platform); + auto platform = std::make_unique< FltkPlatform >(); + Layout *layout = new Layout (std::move( platform )); style::Color *bgColor = style::Color::create (layout, prefs.bg_color); layout->setBgColor (bgColor); layout->setBgImage (NULL, style::BACKGROUND_REPEAT,