I plumbed out ownership a bit and it hasn't crashed yet.
This commit is contained in:
27
dw/layout.cc
27
dw/layout.cc
@ -362,7 +362,7 @@ void Layout::detachWidget (Widget *widget)
|
||||
it->unref ();
|
||||
}
|
||||
|
||||
void Layout::addWidget (Widget *widget)
|
||||
void Layout::addWidget (std::unique_ptr< Widget > widget)
|
||||
{
|
||||
if (topLevel) {
|
||||
MSG_WARN("widget already set\n");
|
||||
@ -372,22 +372,21 @@ void Layout::addWidget (Widget *widget)
|
||||
// The toplevel widget always establishes a stacking context. It could
|
||||
// already be set in Widget::setStyle().
|
||||
if (widget->stackingContextMgr == NULL && IMPL_POS) {
|
||||
widget->stackingContextMgr = new StackingContextMgr (widget);
|
||||
DBG_OBJ_ASSOC (widget, widget->stackingContextMgr);
|
||||
widget->stackingContextWidget = widget;
|
||||
widget->stackingContextMgr = new StackingContextMgr (widget.get());
|
||||
DBG_OBJ_ASSOC (widget.get(), widget->stackingContextMgr);
|
||||
widget->stackingContextWidget = widget.get();
|
||||
}
|
||||
|
||||
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);
|
||||
Widget *widget_p= widget.get();
|
||||
topLevel = std::move( widget );
|
||||
widget_p->layout = this;
|
||||
widget_p->container = NULL;
|
||||
DBG_OBJ_SET_PTR_O (widget_p, "container", widget_p->container);
|
||||
|
||||
queueResizeList->clear ();
|
||||
widget->notifySetAsTopLevel ();
|
||||
widget_p->notifySetAsTopLevel ();
|
||||
|
||||
findtextState.setWidget (widget);
|
||||
findtextState.setWidget (widget_p);
|
||||
|
||||
canvasHeightGreater = false;
|
||||
DBG_OBJ_SET_SYM ("canvasHeightGreater",
|
||||
@ -435,7 +434,9 @@ void Layout::setWidget (Widget *widget)
|
||||
topLevel.reset();
|
||||
}
|
||||
textZone->zoneFree ();
|
||||
addWidget (widget);
|
||||
std::unique_ptr< Widget > widget_unique;
|
||||
widget_unique.reset( widget );
|
||||
addWidget (std::move( widget_unique ));
|
||||
|
||||
updateCursor ();
|
||||
|
||||
|
@ -282,7 +282,7 @@ public:
|
||||
|
||||
lout::misc::ZoneAllocator *textZone;
|
||||
|
||||
void addWidget (Widget *widget);
|
||||
void addWidget (std::unique_ptr< Widget > widget);
|
||||
void setWidget (Widget *widget);
|
||||
|
||||
void attachView (View *view);
|
||||
|
Reference in New Issue
Block a user