News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

wxSmith generate wrong Parent

Started by lastowne, March 03, 2021, 03:15:03 AM

Previous topic - Next topic

lastowne

Hi,
I'm really new to Code::Blocks and wxSmith.
After a while of trying to add a wxTextCtrl to a wxToolBar with wxSmith i finally managed to add it with "insert new widgets in the current selection" button.
But i'm getting an error :

../../src/common/tbarbase.cpp(230): assert "control->GetParent() == this" failed in InsertControl(): control must have toolbar as parent

The problem is that wxSmith adds the wxTextCtrl with "This" instead of "ToolBar1"

Generated by wxSmith:
    TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    ToolBar1->AddControl(TextCtrl1);


It should be:
    TextCtrl1 = new wxTextCtrl(ToolBar1, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    ToolBar1->AddControl(TextCtrl1);


How to fix it? Or i'm i missing something?

Thanks you!

Miguel Gimenez

This looks like a bug with far from trivial fix, please create a ticket.

As a workaround you can try putting this in TextCtrl1's "Extra code" field:
TextCtrl1->Reparent(ToolBar1);