Started plumbing out the ownership from layout.

It seems to not crash, yet.
This commit is contained in:
2025-04-18 02:46:18 -04:00
parent 80f980a2e1
commit fc9a191582
3 changed files with 9 additions and 10 deletions

View File

@ -327,10 +327,8 @@ Layout::~Layout ()
if (bgImage)
bgImage->unref ();
if (topLevel) {
detachWidget (topLevel);
Widget *w = topLevel;
topLevel = NULL;
delete w;
detachWidget (topLevel.get());
topLevel.reset();
}
delete queueResizeList;
@ -379,7 +377,9 @@ void Layout::addWidget (Widget *widget)
widget->stackingContextWidget = widget;
}
topLevel = widget;
std::unique_ptr< Widget > widget_unique;
widget_unique.reset( widget );
topLevel = std::move( widget_unique );
widget->layout = this;
widget->container = NULL;
DBG_OBJ_SET_PTR_O (widget, "container", widget->container);
@ -432,9 +432,7 @@ void Layout::setWidget (Widget *widget)
widgetAtPoint = NULL;
if (topLevel) {
Widget *w = topLevel;
topLevel = NULL;
delete w;
topLevel.reset();
}
textZone->zoneFree ();
addWidget (widget);

View File

@ -158,7 +158,8 @@ private:
Platform *platform;
View *view;
Widget *topLevel, *widgetAtPoint;
std::unique_ptr< Widget > topLevel;
Widget *widgetAtPoint;
lout::container::typed::Vector<Widget> *queueResizeList;
/* The state, which must be projected into the view. */

View File

@ -214,7 +214,7 @@ void Widget::drawInterruption (View *view, Rectangle *area,
DrawingContext *context)
{
Rectangle thisArea;
if (intersects (layout->topLevel, context->getToplevelArea (), &thisArea))
if (intersects (layout->topLevel.get(), context->getToplevelArea (), &thisArea))
draw (view, &thisArea, context);
context->addWidgetProcessedAsInterruption (this);