wxBoxSizer question (Memory Leak potential)  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
DavidKlecker
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 232
Joined: Sun Nov 29, 2009 10:35 am

wxBoxSizer question (Memory Leak potential)

Postby DavidKlecker » Thu Mar 18, 2010 3:13 pm

I used DialogBlocks to render code for a dialog box and in the CreateControls method it builds there are a lot of references to wxBoxSizer and other related Static fields that have the following code

Code: Select all

wxBoxSizer *BoxSizer1 = new wxBoxSizer(...); //the ellipse is just to show a parameter exists but is not important.


My question is, I cannot call delete BoxSizer1 at the end of this method or I will crash the application? Does wxWidgets handle the deletion of BoxSizer1? I don't see how but maybe I'm missing something.

I realize the quickest solution here is just put the wxBoxSizer *BoxSizer1 in the class Object created rather than have it local to the method but if wxWidgets does handle this somehow it does save the work.

Thanks!

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

  [SOLVED]

Postby Auria » Thu Mar 18, 2010 3:18 pm

When a frame is deleted, all of its content is automatically deleted along it (recursively), so as long as the sizer is assigned to some frame there should be no leaks
"Keyboard not detected. Press F1 to continue"
-- Windows

DavidKlecker
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 232
Joined: Sun Nov 29, 2009 10:35 am

Postby DavidKlecker » Thu Mar 18, 2010 3:49 pm

Ah okay. Thanks


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 3 guests