Bug #1030
closedDestroying allocated objects
0%
Description
Hello, the code below was copied from "hello.wt" project.
nameEdit_ object is allocated dynamically using the "new" operator.
is the object deleted or destroyed automatically when the WApplication is destroyed ?
Thank you in advance for your answer
@HelloApplication::HelloApplication(const WEnvironment& env)
: WApplication(env)
{
setTitle("Hello world"); // application title
root()->addWidget(new WText("Your name, please ? ")); // show some text
nameEdit_ = new WLineEdit(root()); // allow text input
nameEdit_->setFocus(); // give focus
WPushButton *b = new WPushButton("Greet me.", root()); // create a button
b->setMargin(5, Left); // add 5 pixels margin
root()->addWidget(new WBreak()); // insert a line break
greeting_ = new WText(root()); // empty text
@
Updated by Koen Deforche about 14 years ago
- Status changed from New to Resolved
Hey,
Yes, the line edit is deleted. Ownership of widgets is transferred to their parent, in this case root(), when the widget is inserted in the widget hierarchy.
See: http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WWidget.html#_details
and: http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WObject.html#_details
Regards,
koen
Updated by Koen Deforche about 14 years ago
- Status changed from Resolved to Closed
- Target version set to 3.2.0