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
This commit is contained in:
SoftFever
2026-06-26 01:20:38 +08:00
committed by GitHub
parent b06305f990
commit e3b4c6df84

View File

@@ -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<int, Material *>;
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(57), FromDIP(32))
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE2 wxSize(FromDIP(80), FromDIP(32))