Actions
Bug #4790
openWt::WObject::addChild() bug
Start date:
03/04/2016
Due date:
% Done:
0%
Estimated time:
Description
Take the following example
MyLineEdit::MyLineEdit(WContainerWidget *parent) : WLineEdit(parent)
{
_btn = new WPushButton();
WObject::addChild(_btn);
}
WPushButton *MyLineEdit::getButton() const
{
return _btn;
}
MyTemplate::MyTemplate()
{
_myLineEdit = new MyLineEdit();
bindWidget("edit", _myLineEdit);
bindWidget("btn", _myLineEdit->getButton()); //Assertion failed: children_ != 0, file ...\src\Wt\WWebWidget.C, line 319
}
What I'm doing is setting _btn
's parent to _myLineEdit
so that if _btn
is not reparented, it should be deleted along with _myLineEdit
. However, when MyTemplate
's constructor tries to reparent _btn
the assertion in WWebWidget::removeChild()
fails. That is because I used WObject::addChild()
which does not create WWebWidget::children_
but instead creates WWidget::children_
Updated by Koen Deforche almost 9 years ago
- Status changed from New to Feedback
- Assignee set to Koen Deforche
- Target version set to 4.0.0
Hey, you're correctly observing a messy situation in WObject:: versus WWebWidget:: addChild(), which leads to this error. This will be fixed in Wt4 (where we move to C++11 unique_ptr for widget ownership (and shared_ptr for models, etc...)).
Actions