Make sure all widgets have a parent.

This commit is contained in:
Mark de Wever 2008-10-31 18:45:25 +00:00
parent 8371027b33
commit b08ae9ce97
4 changed files with 9 additions and 4 deletions

View file

@ -99,7 +99,8 @@ void tgrid::set_child(twidget* widget, const unsigned row,
}
twidget* tgrid::swap_child(
const std::string& id, twidget* widget, const bool recurse)
const std::string& id, twidget* widget, const bool recurse,
twidget* new_parent)
{
assert(widget);
@ -124,7 +125,7 @@ twidget* tgrid::swap_child(
// When find the widget there should be a widget.
twidget* old = child.widget();
assert(old);
old->set_parent(NULL);
old->set_parent(new_parent);
widget->set_parent(this);
child.set_widget(widget);

View file

@ -133,13 +133,15 @@ public:
* @param id The id of the widget to free.
* @param widget The widget to put in the grid.
* @parem recurse Do we want to decent into the child grids.
* @parem new_parent The new parent for the swapped out widget.
*
* returns The widget which got removed (the parent of
* the widget is cleared). If no widget found
* and thus not replace NULL will returned.
*/
twidget* swap_child(
const std::string& id, twidget* widget, const bool recurse);
const std::string& id, twidget* widget, const bool recurse,
twidget* new_parent = NULL);
/**
* Removes and frees a widget in a cell.

View file

@ -409,7 +409,7 @@ void tvertical_scrollbar_container_::show_scrollbar(const bool show)
tgrid* tmp = new tgrid();
scrollbar_grid_ = dynamic_cast<tgrid*>
(grid().swap_child("_scrollbar_grid", tmp, true));
(grid().swap_child("_scrollbar_grid", tmp, true, this));
}
}

View file

@ -109,9 +109,11 @@ twindow::twindow(CVideo& video,
load_config();
tooltip_.set_definition("default");
tooltip_.set_parent(this);
tooltip_.set_visible(false);
help_popup_.set_definition("default");
help_popup_.set_parent(this);
help_popup_.set_visible(false);
}