[erlang-bugs] wxErlang: using wxSizer with wxStaticBox causes shell crash on frame close

Steve Davis <>
Sat Mar 14 23:41:26 CET 2009

More info: This is not wxErlang per se but the wxWidgets code.

While the erlang code below is "legal", the wxWidgets documentation for 
wxStaticBoxSizer explicitly states that it should be added as a sibling 
to the controls that should be visually enclosed, and not used as a 
parent; and that using it as a parent will cause a crash.

However, perhaps wxErlang can catch that problem before it results in a 
complete system thread crash that takes erl/werl with it?


Steve Davis wrote:
> Dan and co.
> This is reproable on Windows XP SP3, I don't have another platform to 
> hand...
> The following function contains a line that causes a SHELL crash on 
> frame close.
> Note! the exactly equivalent code using wxPanel does not cause the crash.
> %% Function causes shell to crash on top level window close... why?
> box(Parent, Opts) ->
>     GxName = get_atom(id, Opts),
>     Label = get_string(label, Opts),
>     Box = wxStaticBox:new(Parent, -1, Label),
>     %% Do sizer stuff...
>     Sizer = wxStaticBoxSizer:new(Box, ?wxVERTICAL),   
>     wxWindow:setSizer(Box, Sizer),
>     SizerFlags = wxSizerFlags:new(),
>     wxSizerFlags:expand(SizerFlags),
>     ParentSizer = wxWindow:getSizer(Parent),
> % layout doesn't doesn't work without the following line...
>     wxSizer:add(ParentSizer, Sizer, SizerFlags),
> % ...but this sizer addition crashes the SHELL on top level window close
>     wxSizer:fit(Sizer, Parent),   
>     gx:register(GxName, Box).
> BR,
> Steve

More information about the erlang-bugs mailing list