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