Project

General

Profile

Actions

Bug #1030

closed

Destroying allocated objects

Bug #1030: Destroying allocated objects

Added by Anonymous almost 15 years ago. Updated almost 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
10/18/2011
Due date:
% Done:

0%

Estimated time:

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
@

KD Updated by Koen Deforche almost 15 years ago Actions #1

  • 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

KD Updated by Koen Deforche almost 15 years ago Actions #2

  • Status changed from Resolved to Closed
  • Target version set to 3.2.0
Actions

Also available in: PDF Atom