Load the CAD recipe from projects saved before it was renamed

The recipe's 3MF entry moved from Metadata/SnapOrca_cad.bin to
Metadata/orca_cad.bin, so projects saved by earlier builds opened with an
empty Design tab. Both 3MF backends now read either name and write only the
new one; the recipe version advances to 6 to mark the move.
This commit is contained in:
SoftFever
2026-08-29 01:56:48 +08:00
parent 0fc62d03b9
commit 8f014de84c
7 changed files with 191 additions and 14 deletions
+7 -1
View File
@@ -3808,7 +3808,13 @@ bool CadDocument::deserialize_recipe(const std::string& blob)
+ std::to_string(ORCA_CAD_RECIPE_VERSION) + ")";
return false;
}
if (v == 5) {
// The framed layout has been byte-identical since v5 (v6 advanced the stamp without
// touching the bytes), so every version from 5 up is read below. A future bump that DOES
// change the framing must exclude itself there — this is what forces that decision
// instead of letting a v7 blob be silently misread by the v5 reader.
static_assert(ORCA_CAD_RECIPE_VERSION <= 6,
"recipe version bumped: confirm the new version still uses the v5 framing");
if (v >= 5) {
// Framed path: every feature is a length-prefixed self-contained cereal stream, so
// the same four lines handle BOTH directions of mismatch. Older file, newer build:
// the sub-stream ends early, fa(f) throws, and the fields already assigned are kept
+4 -2
View File
@@ -639,8 +639,10 @@ public:
// v5: every feature is length-framed, so a reader can stop early on an older file and skip
// the tail of a newer one. This is the LAST version that has to break anything — from here a
// new field only needs appending to save/load, with no bump and no orphaned projects.
// v4 is still read, by the pre-framing flat path, so existing projects keep opening.
static constexpr uint32_t ORCA_CAD_RECIPE_VERSION = 5;
// v6: no wire-format change — the bytes are v5's, and both are read by the same framed path.
// The stamp advances only to put a project-container change on the record; the 3MF backends
// own that story. v4 still opens through the pre-framing flat path.
static constexpr uint32_t ORCA_CAD_RECIPE_VERSION = 6;
std::string serialize_recipe() const;
bool deserialize_recipe(const std::string& blob);
+5 -1
View File
@@ -74,6 +74,9 @@ const std::string PRINT_CONFIG_FILE = "Metadata/Slic3r_PE.config";
const std::string MODEL_CONFIG_FILE = "Metadata/Slic3r_PE_model.config";
const std::string LAYER_HEIGHTS_PROFILE_FILE = "Metadata/Slic3r_PE_layer_heights_profile.txt";
const std::string CAD_RECIPE_FILE = "Metadata/orca_cad.bin";
// Read-only: the recipe entry's pre-rename name. A reader that knows only the new one drops the
// feature tree of every project written before the move, without a word. Never written.
const std::string LEGACY_CAD_RECIPE_FILE = "Metadata/SnapOrca_cad.bin";
const std::string LAYER_CONFIG_RANGES_FILE = "Metadata/Prusa_Slicer_layer_config_ranges.xml";
const std::string SLA_SUPPORT_POINTS_FILE = "Metadata/Slic3r_PE_sla_support_points.txt";
const std::string SLA_DRAIN_HOLES_FILE = "Metadata/Slic3r_PE_sla_drain_holes.txt";
@@ -806,7 +809,8 @@ ModelVolumeType type_from_string(const std::string &s)
return false;
}
}
if (boost::algorithm::iequals(name, CAD_RECIPE_FILE)) {
if (boost::algorithm::iequals(name, CAD_RECIPE_FILE)
|| boost::algorithm::iequals(name, LEGACY_CAD_RECIPE_FILE)) {
if (stat.m_uncomp_size > 0) {
std::string buffer((size_t)stat.m_uncomp_size, 0);
if (mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename,
+5 -1
View File
@@ -215,6 +215,9 @@ const std::string SLICE_INFO_CONFIG_FILE = "Metadata/slice_info.config";
const std::string FILAMENT_SEQUENCE_FILE = "Metadata/filament_sequence.json";
const std::string BBS_LAYER_HEIGHTS_PROFILE_FILE = "Metadata/layer_heights_profile.txt";
const std::string ORCA_CAD_RECIPE_FILE = "Metadata/orca_cad.bin";
// Read-only: the recipe entry's pre-rename name. A reader that knows only the new one drops the
// feature tree of every project written before the move, without a word. Never written.
const std::string LEGACY_CAD_RECIPE_FILE = "Metadata/SnapOrca_cad.bin";
const std::string LAYER_CONFIG_RANGES_FILE = "Metadata/layer_config_ranges.xml";
const std::string BRIM_EAR_POINTS_FILE = "Metadata/brim_ear_points.txt";
/*const std::string SLA_SUPPORT_POINTS_FILE = "Metadata/Slic3r_PE_sla_support_points.txt";
@@ -1971,7 +1974,8 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// extract slic3r print config file
_extract_project_config_from_archive(archive, stat, config, config_substitutions, model);
}
else if (boost::algorithm::iequals(name, ORCA_CAD_RECIPE_FILE)) {
else if (boost::algorithm::iequals(name, ORCA_CAD_RECIPE_FILE)
|| boost::algorithm::iequals(name, LEGACY_CAD_RECIPE_FILE)) {
// Restore the editable CAD recipe (optional; absent in non-CAD projects).
if (stat.m_uncomp_size > 0) {
std::string buf((size_t)stat.m_uncomp_size, '\0');