Skip to content

Commit

Permalink
Fix of prusa3d#5152 assert ""HasFlag(0x0020)"" failed in GetSelection…
Browse files Browse the repository at this point in the history
…(): must be single selection listbox

This assert was invoked by list_printer->GetSelection() because of list_printer was created with wxLB_MULTIPLE flag.
  • Loading branch information
YuSanka authored and eyusupov committed May 6, 2021
1 parent 759f733 commit 128797c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
21 changes: 9 additions & 12 deletions src/slic3r/GUI/ConfigWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,13 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
append(html_window, 0, wxEXPAND);

list_printer->Bind(wxEVT_LISTBOX, [this](wxCommandEvent& evt) {
update_lists(evt.GetInt(), list_type->GetSelection(), list_vendor->GetSelection());
update_lists(list_type->GetSelection(), list_vendor->GetSelection(), evt.GetInt());
});
list_type->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) {
update_lists(list_printer->GetSelection(), list_type->GetSelection(), list_vendor->GetSelection());
update_lists(list_type->GetSelection(), list_vendor->GetSelection());
});
list_vendor->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) {
update_lists(list_printer->GetSelection(), list_type->GetSelection(), list_vendor->GetSelection());
update_lists(list_type->GetSelection(), list_vendor->GetSelection());
});

list_profile->Bind(wxEVT_CHECKLISTBOX, [this](wxCommandEvent &evt) { select_material(evt.GetInt()); });
Expand Down Expand Up @@ -674,8 +674,7 @@ void PageMaterials::reload_presets()
sort_list_data(list_printer, true, false);
if (list_printer->GetCount() > 0) {
list_printer->SetSelection(0);
sel_printer_count_prev = wxNOT_FOUND;
sel_printer_item_prev = wxNOT_FOUND;
sel_printers_prev.Clear();
sel_type_prev = wxNOT_FOUND;
sel_vendor_prev = wxNOT_FOUND;
update_lists(0, 0, 0);
Expand Down Expand Up @@ -805,23 +804,23 @@ void PageMaterials::on_material_highlighted(int sel_material)
set_compatible_printers_html_window(names, names.size() == materials->printers.size());
}

void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected_printer/* = -1*/)
{
wxWindowUpdateLocker freeze_guard(this);
(void)freeze_guard;

wxArrayInt sel_printers;
int sel_printers_count = list_printer->GetSelections(sel_printers);

if (sel_printers_count != sel_printer_count_prev || (sel_printers_count == 1 && sel_printer_item_prev != sel_printer && sel_printer != -1)) {
if (sel_printers != sel_printers_prev) {
// Refresh type list
list_type->Clear();
list_type->append(_L("(All)"), &EMPTY);
if (sel_printers_count > 0) {
// If all is selected with other printers
// unselect "all" or all printers depending on last value
if (sel_printers[0] == 0 && sel_printers_count > 1) {
if (sel_printer == 0) {
if (last_selected_printer == 0) {
list_printer->SetSelection(wxNOT_FOUND);
list_printer->SetSelection(0);
} else {
Expand Down Expand Up @@ -862,8 +861,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
sort_list_data(list_type, true, true);
}

sel_printer_count_prev = sel_printers_count;
sel_printer_item_prev = sel_printer;
sel_printers_prev = sel_printers;
sel_type = 0;
sel_type_prev = wxNOT_FOUND;
list_type->SetSelection(sel_type);
Expand Down Expand Up @@ -1084,8 +1082,7 @@ void PageMaterials::clear()
list_type->Clear();
list_vendor->Clear();
list_profile->Clear();
sel_printer_count_prev = wxNOT_FOUND;
sel_printer_item_prev = wxNOT_FOUND;
sel_printers_prev.Clear();
sel_type_prev = wxNOT_FOUND;
sel_vendor_prev = wxNOT_FOUND;
presets_loaded = false;
Expand Down
5 changes: 3 additions & 2 deletions src/slic3r/GUI/ConfigWizard_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ struct PageMaterials: ConfigWizardPage
Materials *materials;
StringList *list_printer, *list_type, *list_vendor;
PresetList *list_profile;
int sel_printer_count_prev, sel_printer_item_prev, sel_type_prev, sel_vendor_prev;
wxArrayInt sel_printers_prev;
int sel_type_prev, sel_vendor_prev;
bool presets_loaded;

wxFlexGridSizer *grid;
Expand All @@ -342,7 +343,7 @@ struct PageMaterials: ConfigWizardPage
PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name);

void reload_presets();
void update_lists(int sel1, int sel2, int sel3);
void update_lists(int sel_type, int sel_vendor, int last_selected_printer = -1);
void on_material_highlighted(int sel_material);
void on_material_hovered(int sel_material);
void select_material(int i);
Expand Down

0 comments on commit 128797c

Please sign in to comment.