Project

General

Profile

Actions

Bug #3522

closed

Memory Leak in WApplication

Added by Marcel Ebmer over 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Benoit Daccache
Target version:
Start date:
08/09/2014
Due date:
% Done:

0%

Estimated time:

Description

When using a WLoadingIndicator implementation that does NOT inherit from WWidget, the member WApplication::loadingIndicator_ is leaked.

class MyLoadingIndicator : public Wt::WLoadingIndicator {
  ...
  ...
  virtual Wt::WWidget* widget() { return whatever_but_not(this); }
  ...
}

setLoadingIndicator(new MyLoadingIndicator(...));

In this case, WApplication takes ownership of whatever widget() returns, instead of taking ownership of the MyLoadingIndicator* itself.

This leads not only to a memory leak, but also leads to trouble if widget() returns the address of a stack object (e.g. member variable of MyLoadingIndicator)

Suggestion: Take ownership of the LoadingIndicator and make the indicator implementation responsible for memory management.

Actions #1

Updated by Marcel Ebmer over 10 years ago

...for memory management including deleting whatever widget() returns;

Actions #2

Updated by Koen Deforche over 9 years ago

  • Status changed from New to InProgress
  • Assignee set to Benoit Daccache
  • Target version set to 3.3.5
Actions #3

Updated by Benoit Daccache over 9 years ago

  • Status changed from InProgress to Resolved

WLoadingIndicator now derives WObject and can thus receive a parent which will free it.

However the widget returned by widget() will be owned by WApplication and should therefore not be deleted

Actions #4

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF