Fix of #5510: ctrlsub.cpp(231): assert "IsValid(n)" failed in GetClientData(): Invalid index passed to GetClientData()

BitmapComboBox: Use virtual OnSelect() on wxEVT_COMBO event
Don't save information about preset combobox type to the evt.SetInt(). This information can be received from BitmapComboBox::get_type() now.
This commit is contained in:
YuSanka 2021-02-25 12:55:06 +01:00
parent be7e2f2ae1
commit 89f065b57e
3 changed files with 86 additions and 79 deletions

View file

@ -3336,16 +3336,14 @@ void Plater::priv::set_current_panel(wxPanel* panel)
void Plater::priv::on_select_preset(wxCommandEvent &evt)
{
auto preset_type = static_cast<Preset::Type>(evt.GetInt());
auto *combo = static_cast<PlaterPresetComboBox*>(evt.GetEventObject());
PlaterPresetComboBox* combo = static_cast<PlaterPresetComboBox*>(evt.GetEventObject());
Preset::Type preset_type = combo->get_type();
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender"),
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
// So, use GetSelection() from event parameter
// But in this function we couldn't use evt.GetSelection(), because m_commandInt is used for preset_type
// Thus, get selection in this way:
int selection = combo->FindString(evt.GetString(), true);
int selection = evt.GetSelection();
auto idx = combo->get_extruder_idx();