User forums > General (but related to Code::Blocks)
wxSmith generate wrong Parent
(1/1)
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:
--- Code: --- TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
ToolBar1->AddControl(TextCtrl1);
--- End code ---
It should be:
--- Code: --- TextCtrl1 = new wxTextCtrl(ToolBar1, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
ToolBar1->AddControl(TextCtrl1);
--- End code ---
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:
--- Code: ---TextCtrl1->Reparent(ToolBar1);
--- End code ---
Navigation
[0] Message Index
Go to full version