Fix handy model menu failing in RelWithDebInfo (#14102)

* Fix handy model menu failing in RelWithDebInfo; replace pointer-compared labels with a data table
This commit is contained in:
SoftFever
2026-06-08 17:16:54 +08:00
committed by GitHub
parent 8cc56a9e2a
commit 0d586b28c4

View File

@@ -576,55 +576,47 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
wxMenu* MenuFactory::append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type) { wxMenu* MenuFactory::append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type) {
auto sub_menu = new wxMenu; auto sub_menu = new wxMenu;
for (auto &item : {L("Orca Cube"), L("OrcaSliced Combo"), L("Orca Tolerance Test"), L("3DBenchy"), L("Cali Cat"), L("Autodesk FDM Test"), // Orca: handy models shipped under <resources>/handy_models. Defining everything in one table
L("Voron Cube"), L("Stanford Bunny"), L("Orca String Hell") }) { // keeps the menu label, the files to load and the per-model behavior in a single place and
append_menu_item( // avoids repeating the label strings (and the value-vs-pointer comparison pitfalls that come
sub_menu, wxID_ANY, _(item), "", // with that). Labels are wrapped in L() so they are picked up for translation.
[type, item](wxCommandEvent&) { struct HandyModel
std::vector<boost::filesystem::path> input_files; {
bool is_stringhell = false; const char* label;
std::vector<std::string> file_names; std::vector<std::string> file_names;
bool arrange_after_import = false; bool arrange_after_import = false;
if (item == L("Orca Cube")){ bool is_stringhell = false;
file_names = { "OrcaCube_v2.drc", "OrcaPlug_v2.drc"}; };
arrange_after_import = true; static const std::vector<HandyModel> handy_models = {
} {L("Orca Cube"), {"OrcaCube_v2.drc", "OrcaPlug_v2.drc"}, true},
else if (item == L("OrcaSliced Combo")) {L("OrcaSliced Combo"), {"OrcaSliced.3mf", "OrcaCube_v2.drc", "OrcaPlug_v2.drc"}, true},
{ {L("Orca Tolerance Test"), {"OrcaToleranceTest.drc"}},
file_names = { "OrcaSliced.3mf", "OrcaCube_v2.drc", "OrcaPlug_v2.drc" }; {L("3DBenchy"), {"3DBenchy.drc"}},
arrange_after_import = true; {L("Cali Cat"), {"calicat.drc"}},
} {L("Autodesk FDM Test"), {"ksr_fdmtest_v4.drc"}},
else if (item == L("Orca Tolerance Test")) {L("Voron Cube"), {"Voron_Design_Cube_v7.drc"}},
file_names = { "OrcaToleranceTest.drc" }; {L("Stanford Bunny"), {"Stanford_Bunny.drc"}},
else if (item == L("3DBenchy")) {L("Orca String Hell"), {"Orca_stringhell.drc"}, false, true},
file_names = { "3DBenchy.drc" }; };
else if (item == L("Cali Cat"))
file_names = { "calicat.drc" };
else if (item == L("Autodesk FDM Test"))
file_names = { "ksr_fdmtest_v4.drc" };
else if (item == L("Voron Cube"))
file_names = { "Voron_Design_Cube_v7.drc" };
else if (item == L("Stanford Bunny"))
file_names = { "Stanford_Bunny.drc" };
else if (item == L("Orca String Hell")) {
file_names = { "Orca_stringhell.drc" };
is_stringhell = true;
} else
return;
input_files.reserve(file_names.size()); for (const auto& model : handy_models) {
for (const auto& file_name : file_names) append_menu_item(
sub_menu, wxID_ANY, _(model.label), "",
[&model](wxCommandEvent&) {
std::vector<boost::filesystem::path> input_files;
input_files.reserve(model.file_names.size());
for (const auto& file_name : model.file_names)
input_files.push_back((boost::filesystem::path(Slic3r::resources_dir()) / "handy_models" / file_name)); input_files.push_back((boost::filesystem::path(Slic3r::resources_dir()) / "handy_models" / file_name));
plater()->load_files(input_files, LoadStrategy::LoadModel); plater()->load_files(input_files, LoadStrategy::LoadModel);
if (arrange_after_import) { if (model.arrange_after_import) {
plater()->set_prepare_state(Job::PREPARE_STATE_MENU); plater()->set_prepare_state(Job::PREPARE_STATE_MENU);
plater()->arrange(); plater()->arrange();
} }
// Suggest to change settings for stringhell // Suggest to change settings for stringhell
// This serves as mini tutorial for new users // This serves as mini tutorial for new users
if (is_stringhell) { if (model.is_stringhell) {
wxGetApp().CallAfter([=] { wxGetApp().CallAfter([=] {
DynamicPrintConfig* m_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; DynamicPrintConfig* m_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;