Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: winnie on April 11, 2018, 09:43:21 am

Title: wxSmith and wxGridBagSizer
Post by: winnie on April 11, 2018, 09:43:21 am
When I use a wxGridBagSizer with wxSmith and I set the properties Growable cols and Growable rows wxSmith add the code just after the creation of wxGridBagSizer and not after the elements in the grid are added.

Here is the code generated by wxSmith

    wxGridBagSizer* GridBagSizer1;

    Create(parent, id, _("wxWidgets app"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX, _T("id"));
    GridBagSizer1 = new wxGridBagSizer(0, 0);

    //   !!!! these 5 lines of code should be moved after the elements of the grid are added
    GridBagSizer1->AddGrowableCol(0);     
    GridBagSizer1->AddGrowableCol(1);
    GridBagSizer1->AddGrowableRow(0);
    GridBagSizer1->AddGrowableRow(1);
    GridBagSizer1->AddGrowableRow(2);

    Button1 = new wxButton(this, ID_BUTTON1, _("Label"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
    GridBagSizer1->Add(Button1, wxGBPosition(0, 0), wxGBSpan(2, 1), wxALL|wxEXPAND, 5);
    CheckBox1 = new wxCheckBox(this, ID_CHECKBOX1, _("Label"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
    CheckBox1->SetValue(false);
    GridBagSizer1->Add(CheckBox1, wxGBPosition(0, 1), wxDefaultSpan, wxALL|wxEXPAND, 5);
    Choice1 = new wxChoice(this, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
    GridBagSizer1->Add(Choice1, wxGBPosition(1, 1), wxDefaultSpan, wxALL|wxEXPAND, 5);
    Button2 = new wxButton(this, ID_BUTTON2, _("Label"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
    GridBagSizer1->Add(Button2, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL|wxEXPAND, 5);
    SetSizer(GridBagSizer1);
    GridBagSizer1->Fit(this);
    GridBagSizer1->SetSizeHints(this);
    //*)

Title: Re: wxSmith and wxGridBagSizer
Post by: oBFusCATed on April 11, 2018, 10:23:04 am
Why?
Title: Re: wxSmith and wxGridBagSizer
Post by: winnie on April 13, 2018, 05:04:45 pm
Because when I run the program I get the following error:

../src/common/sizer.cpp(1980): assert "!m_cols || idx < (size_t)m_cols" failed in AddGrowableCol(): invalid column index

It gives the problem only for the columns and not for the rows. I don't know why but if you try in this way it doesn't work.
Title: Re: wxSmith and wxGridBagSizer
Post by: stahta01 on April 13, 2018, 07:55:56 pm
winnie: What Code::Blocks version?
What operating system version?
What wxWidgets version are you using to build your C:B: project?

Tim S.

Title: Re: wxSmith and wxGridBagSizer
Post by: BlueHazzard on April 14, 2018, 06:35:54 pm
I can reproduce this...
This new wxWidgets asserts are annoying as fuck....

will try to create a fix....
Title: Re: wxSmith and wxGridBagSizer
Post by: oBFusCATed on April 14, 2018, 06:58:17 pm
No they are not. They report real problems most of the times. The code is broken.
Btw if you don't want to see them define NDEBUG and they'll be gone.
Title: Re: wxSmith and wxGridBagSizer
Post by: BlueHazzard on April 15, 2018, 10:38:00 pm
Ticket: https://sourceforge.net/p/codeblocks/tickets/664/

We have two problems here:
1) The generated code is not correct. (An assert is triggered by the user application)
2) The code that is used for the preview is also not correct. (An assert is triggered by the wxSmith plugin)

for 1) i have a patch already

fixed both problems in the ticket


Title: Re: wxSmith and wxGridBagSizer
Post by: oBFusCATed on April 29, 2018, 06:28:04 pm
Should be fixed in trunk.