From b073f58a8e96ab3224c67550672a051e61a718e8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 1 Apr 2022 12:41:59 +0200 Subject: Fix T96930: Cloth Disk cache not being saved and being deleted on files that have been linked and library override enabled. PointCache handing is just horrible from RNA, makes dealing with overrides a nightmare... Ended up having to add a specific 'apply' callback for the `use_disk_cache` property, that would explicitely NOT call the the `update` callback of this property, to avoid having the whole disk cache nuked away... But the whole thing remains fairly britle, to say the least. --- source/blender/makesrna/intern/rna_object_force.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index ca8c1876887..ce4b1a193a3 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -49,6 +49,8 @@ static const EnumPropertyItem effector_shape_items[] = { # include "BLI_math_base.h" +# include "RNA_access.h" + /* type specific return values only used from functions */ static const EnumPropertyItem curve_shape_items[] = { {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"}, @@ -239,6 +241,33 @@ static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene } } +bool rna_Cache_use_disk_cache_override_apply(Main *UNUSED(bmain), + PointerRNA *ptr_dst, + PointerRNA *ptr_src, + PointerRNA *UNUSED(ptr_storage), + PropertyRNA *prop_dst, + PropertyRNA *prop_src, + PropertyRNA *UNUSED(prop_storage), + const int UNUSED(len_dst), + const int UNUSED(len_src), + const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), + PointerRNA *UNUSED(ptr_item_src), + PointerRNA *UNUSED(ptr_item_storage), + IDOverrideLibraryPropertyOperation *opop) +{ + BLI_assert(RNA_property_type(prop_dst) == PROP_BOOLEAN); + BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE); + UNUSED_VARS_NDEBUG(opop); + + RNA_property_boolean_set(ptr_dst, prop_dst, RNA_property_boolean_get(ptr_src, prop_src)); + + /* DO NOT call `RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);`, that would trigger + * the whole 'update from mem point cache' process, ending up in the complete deletion of an + * existing diskcache if any. */ + return true; +} + static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = NULL; @@ -983,6 +1012,7 @@ static void rna_def_pointcache_common(StructRNA *srna) RNA_def_property_ui_text( prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache"); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Cache_use_disk_cache_override_apply"); prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED); -- cgit v1.2.3