Bug #3522
closedMemory Leak in WApplication
0%
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.
Updated by Marcel Ebmer over 10 years ago
...for memory management including deleting whatever widget() returns;
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
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
Updated by Koen Deforche over 9 years ago
- Status changed from Resolved to Closed