User forums > General (but related to Code::Blocks)

WxSmith generate wrong code with sizer

(1/3) > >>

gst0098:
Platform: CodeBlocks 13.12, ArchLinux

wxSmith generates code that cause segfault when executed, this is an exerpt of the generated code:


--- Code: ---    inner_sizer->Add(Panel7, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
    Panel5->SetSizer(inner_sizer);
    SetSizer(inner_sizer);
    Layout();

--- End code ---

When executed it segfaults at the Layout() line. The above code is assigning the same sizer to multiple windows, is this correct ? I believe not and in fact I found that commenting the SetSizer(inner_sizer) line solves the problem and the program runs.

Thanks in advance,
Giuseppe

MortenMacFly:
Please provide a sample project to reproduce.it looks more like a wx layout issue to me...

gst0098:

--- Quote from: MortenMacFly on June 25, 2014, 08:12:58 pm ---Please provide a sample project to reproduce.it looks more like a wx layout issue to me...

--- End quote ---

The project is big, I extracted in a new project only some parts of the UI, the behaviour is exactly as the orginal project, wxSmith apprently generates wrong code.

The project is attached.

Thanks,
Giuseppe

gst0098:
Still I can't find any workaorunds to the problem, the problems looks related to the way wxSmith generate code for the layout manager, it duplicates the assignment of the the same sizer to different panels, this generates the segfault.

I'm hoping this behaviour will be fixed in future releases.

I cannot understand why no one as reported this before.
Is anyone kind to try the attached code ? Maybe the problem is related to my configuration/installation.

Giuseppe


--- Quote from: gst0098 on June 30, 2014, 02:35:45 pm ---
--- Quote from: MortenMacFly on June 25, 2014, 08:12:58 pm ---Please provide a sample project to reproduce.it looks more like a wx layout issue to me...

--- End quote ---

The project is big, I extracted in a new project only some parts of the UI, the behaviour is exactly as the orginal project, wxSmith apprently generates wrong code.

The project is attached.

Thanks,
Giuseppe

--- End quote ---

cacb:

--- Quote from: gst0098 on July 21, 2014, 03:59:36 pm ---Still I can't find any workaorunds to the problem, the problems looks related to the way wxSmith generate code for the layout manager, it duplicates the assignment of the the same sizer to different panels, this generates the segfault.

I'm hoping this behaviour will be fixed in future releases.

I cannot understand why no one as reported this before.
Is anyone kind to try the attached code ? Maybe the problem is related to my configuration/installation.

Giuseppe

--- End quote ---

Guiseppe,

I tried your code quickly under Kubuntu 14.04 and using wx3.0. Sure enough it caused problems. However I cannot say exactly why. It seems strange that Layout() is called several times (6 times!!) in your main frame constructor. I think somehow you've managed to fool the system.

But your code seems overly complex using FlexGridSizer etc. in many layers. In my experience this can be asking for trouble. I started deleting until it worked, but I couldn't pinpoint the issue directly. I would recommend keeping the number of layers in the GUI design less complicated. One way I have done that is using only wxBoxSizers vertical/horizontal as needed, it tends to work fine (many layers also, but simpler).

But lately, I have started using wxAUI for these things. It looks better, it is easier to use and far more flexible with docking support etc. Generally drop a wxAuiManager into the main frame, and add panels to it.

Whether or not I use AUI, I tend to create custom panels (all the time using wxSmith) and add them to notebooks or AUI. I find that the application structure becomes cleaner (IMHO) that way.

So I think you have to prototype a layout until you find something that works. Test for every new complexity you add, so you are able to identify where problems begin.

Navigation

[0] Message Index

[#] Next page

Go to full version