MSW specific: ObjectList: Fixed eternal Editor Control

Steps to reproduce of a bug:
1. Add object
2. Click the Cog icon with the left mouse button
3. DoubleClick on name of object > An Editor Control appears that cannot be deleted any way
This commit is contained in:
YuSanka 2021-09-10 14:07:29 +02:00
parent 34c4b74af4
commit 3db4804e47

View file

@ -197,6 +197,17 @@ wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRec
labelRect.SetWidth(labelRect.GetWidth() - bmp_width);
}
#ifdef __WXMSW__
// Case when from some reason we try to create next EditorCtrl till old one was not deleted
if (auto children = parent->GetChildren(); children.GetCount() > 0)
for (auto child : children)
if (dynamic_cast<wxTextCtrl*>(child)) {
parent->RemoveChild(child);
child->Destroy();
break;
}
#endif // __WXMSW__
wxTextCtrl* text_editor = new wxTextCtrl(parent, wxID_ANY, data.GetText(),
position, labelRect.GetSize(), wxTE_PROCESS_ENTER);
text_editor->SetInsertionPointEnd();