Ownership of Platform in part of the code.

This commit is contained in:
2025-04-19 01:02:59 -04:00
parent 4ba2146cd1
commit 918a283748
3 changed files with 6 additions and 7 deletions

View File

@ -257,7 +257,7 @@ Layout::Anchor::~Anchor ()
Layout::Layout (std::unique_ptr< Platform > platform, bool limit) Layout::Layout (std::unique_ptr< Platform > platform, bool limit)
{ {
this->platform = platform.release(); this->platform = std::move( platform );
view = NULL; view = NULL;
topLevel = NULL; topLevel = NULL;
widgetAtPoint = 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 (&findtextState);
DBG_OBJ_ASSOC_CHILD (&selectionState); DBG_OBJ_ASSOC_CHILD (&selectionState);
platform->setLayout (this); this->platform->setLayout (this);
selectionState.setLayout(this); selectionState.setLayout(this);
@ -329,7 +329,6 @@ Layout::~Layout ()
topLevel.reset(); topLevel.reset();
} }
delete platform;
delete view; delete view;
delete textZone; delete textZone;

View File

@ -157,7 +157,7 @@ private:
~Anchor (); ~Anchor ();
}; };
Platform *platform; std::unique_ptr< Platform > platform;
View *view; View *view;
std::unique_ptr< Widget > topLevel; std::unique_ptr< Widget > topLevel;
Widget *widgetAtPoint; Widget *widgetAtPoint;
@ -349,7 +349,7 @@ public:
inline Platform *getPlatform () inline Platform *getPlatform ()
{ {
return platform; return platform.get();
} }
/* delegated */ /* delegated */

View File

@ -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); UI *new_ui = tabs->add_new_tab(old_ui, focus);
// Now create the Dw render layout and viewport // Now create the Dw render layout and viewport
FltkPlatform *platform = new FltkPlatform (); auto platform = std::make_unique< FltkPlatform >();
Layout *layout = new Layout (platform); Layout *layout = new Layout (std::move( platform ));
style::Color *bgColor = style::Color::create (layout, prefs.bg_color); style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
layout->setBgColor (bgColor); layout->setBgColor (bgColor);
layout->setBgImage (NULL, style::BACKGROUND_REPEAT, layout->setBgImage (NULL, style::BACKGROUND_REPEAT,