From e3b4c6df84ca4e3c2fa3ed06e42cf7da64ba19ea Mon Sep 17 00:00:00 2001 From: SoftFever Date: Fri, 26 Jun 2026 01:20:38 +0800 Subject: [PATCH] Fix AMS overwrite sync showing filaments in wrong order (#14335) (#14408) Syncing the filament list from AMS with the "Overwriting" option displayed the AMS filaments in the wrong (reversed) order in the preview, even though the filament mapping that was actually applied was correct. Reported on macOS with a Bambu X1C. The preview depends on MaterialHash being iterated in material-index order. MaterialHash is a WX_DECLARE_HASH_MAP, which under OrcaSlicer's current wxWidgets 3.3 build (wxUSE_STD_CONTAINERS=1) resolves to std::unordered_map; its iteration order is unspecified and on macOS (libc++) comes out reversed, which scrambled the preview. The same code is unaffected in BambuStudio because its older wxWidgets build still uses wx's own key-ordered hash table, so this only became visible after the wx upgrade. Fixes #14335 --- src/slic3r/GUI/SelectMachine.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index f0e135f33e..ab88240ec0 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -100,7 +100,11 @@ enum class ConfigNozzleIdx : int }; -WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash); +// Orca: MaterialHash is keyed by material/extruder index and is iterated in key order in +// several places (e.g. the AMS override preview), so it must be an ordered container. +// std::unordered_map (what WX_DECLARE_HASH_MAP expands to under wxUSE_STD_CONTAINERS=1) +// iterates in an unspecified, implementation-dependent order, which scrambled that preview. +using MaterialHash = std::map; #define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(57), FromDIP(32)) #define SELECT_MACHINE_DIALOG_BUTTON_SIZE2 wxSize(FromDIP(80), FromDIP(32))