Anim: fix crash when loading F-Curve with unknown modifier

When loading a blend file that has an F-Curve with an unknown modifier
on it, this should be gracefully handled.

Pull Request: https://projects.blender.org/blender/blender/pulls/145574
This commit is contained in:
Sybren A. Stüvel
2025-09-02 16:08:38 +02:00
parent 8b220fa4cf
commit 15922bec71
2 changed files with 15 additions and 1 deletions

View File

@@ -2517,7 +2517,13 @@ void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBase *fmodifier
fcm->data = BLO_read_struct_by_name_array(reader, fmi->struct_name, 1, fcm->data);
}
else {
BLI_assert_unreachable();
/* This can happen when the blend file has data for a modifier that doesn't exist in this
* Blender version (when the blend file is newer). */
BLO_reportf_wrap(BLO_read_data_reports(reader),
RPT_WARNING,
RPT_("F-Curve modifier lost on '%s[%d]' because it has an unknown type"),
curve->rna_path,
curve->array_index);
fcm->data = nullptr;
}
fcm->curve = curve;

View File

@@ -1386,6 +1386,14 @@ static void graph_fmodifier_panel_id(void *fcm_link, char *r_name)
FModifier *fcm = (FModifier *)fcm_link;
eFModifier_Types type = eFModifier_Types(fcm->type);
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
if (!fmi) {
/* This can happen when the blend file has data for a modifier that doesn't exist in this
* Blender version (when the blend file is newer). */
r_name[0] = '\0';
return;
}
BLI_snprintf_utf8(r_name, BKE_ST_MAXNAME, "%s_PT_%s", GRAPH_FMODIFIER_PANEL_PREFIX, fmi->name);
}