diff options
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 21 | ||||
-rw-r--r-- | tests/python/bl_blendfile_library_overrides.py | 10 |
2 files changed, 23 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 6df03d19538..e177f211c7f 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -741,6 +741,19 @@ static void rna_ID_override_template_create(ID *id, ReportList *reports) BKE_lib_override_library_template_create(id); } +static void rna_ID_override_library_update_operations(ID *id, + IDOverrideLibrary *UNUSED(override_library), + Main *bmain, + ReportList *reports) +{ + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + BKE_report(reports, RPT_ERROR, "ID isn't an override"); + return; + } + + BKE_lib_override_library_operations_create(bmain, id); +} + static IDOverrideLibraryProperty *rna_ID_override_library_properties_add( IDOverrideLibrary *override_library, ReportList *reports, const char rna_path[]) { @@ -1695,6 +1708,7 @@ static void rna_def_ID_override_library(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; srna = RNA_def_struct(brna, "IDOverrideLibrary", NULL); RNA_def_struct_ui_text( @@ -1710,6 +1724,13 @@ static void rna_def_ID_override_library(BlenderRNA *brna) "List of overridden properties"); rna_def_ID_override_library_properties(brna, prop); + /* Update function. */ + func = RNA_def_function(srna, "update_operations", "rna_ID_override_library_update_operations"); + RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_SELF_ID | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, + "Update the library override operations based on the " + "differences between this override ID and its reference"); + rna_def_ID_override_library_property(brna); } diff --git a/tests/python/bl_blendfile_library_overrides.py b/tests/python/bl_blendfile_library_overrides.py index c9c89c01cee..138c5fd13b5 100644 --- a/tests/python/bl_blendfile_library_overrides.py +++ b/tests/python/bl_blendfile_library_overrides.py @@ -45,10 +45,6 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): bpy.ops.wm.save_as_mainfile(filepath=str(self.output_path), check_existing=False, compress=False) - def __ensure_override_library_updated(self): - # During save the override_library is updated. - bpy.ops.wm.save_as_mainfile(filepath=str(self.test_output_path), check_existing=False, compress=False) - def test_link_and_override_property(self): bpy.ops.wm.read_homefile(use_empty=True, use_factory_startup=True) bpy.data.orphans_purge() @@ -64,8 +60,7 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): assert(len(local_id.override_library.properties) == 0) local_id.location.y = 1.0 - - self.__ensure_override_library_updated() + local_id.override_library.update_operations() assert(len(local_id.override_library.properties) == 1) override_prop = local_id.override_library.properties[0] @@ -101,7 +96,6 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): override_operation = override_prop.operations[0] assert(override_operation.operation == 'NOOP') assert(override_operation.subitem_local_index == -1) - local_id.location.y = 1.0 local_id.scale.x = 0.5 # `scale.x` will apply, but will be reverted when the library overrides @@ -110,7 +104,7 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): assert(local_id.scale.x == 0.5) assert(local_id.location.y == 1.0) - self.__ensure_override_library_updated() + local_id.override_library.update_operations() assert(local_id.scale.x == 1.0) assert(local_id.location.y == 1.0) |