Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-04-15 18:26:34 +0300
committerBastien Montagne <bastien@blender.org>2020-04-16 17:21:11 +0300
commit0438944b343ed11abad47964f4dccb4e171da179 (patch)
tree0b7eeab5d28b4d7ddc7f6bd90873cc23edf1cdc5 /source/blender/blenkernel
parente3d575b37651b20b281f431047d97b43c0ce028d (diff)
Refactor/strengthen a bit invalid operands checks when applying an override operation.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_lib_override.h11
-rw-r--r--source/blender/blenkernel/intern/lib_override.c40
2 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h
index 6f2882f3565..699d1ee23e9 100644
--- a/source/blender/blenkernel/BKE_lib_override.h
+++ b/source/blender/blenkernel/BKE_lib_override.h
@@ -48,6 +48,8 @@ struct IDOverrideLibrary;
struct IDOverrideLibraryProperty;
struct IDOverrideLibraryPropertyOperation;
struct Main;
+struct PointerRNA;
+struct PropertyRNA;
void BKE_lib_override_library_enable(const bool do_enable);
bool BKE_lib_override_library_is_enabled(void);
@@ -92,6 +94,15 @@ void BKE_lib_override_library_property_operation_delete(
struct IDOverrideLibraryProperty *override_property,
struct IDOverrideLibraryPropertyOperation *override_property_operation);
+bool BKE_lib_override_library_property_operation_operands_validate(
+ struct IDOverrideLibraryPropertyOperation *override_property_operation,
+ struct PointerRNA *ptr_dst,
+ struct PointerRNA *ptr_src,
+ struct PointerRNA *ptr_storage,
+ struct PropertyRNA *prop_dst,
+ struct PropertyRNA *prop_src,
+ struct PropertyRNA *prop_storage);
+
bool BKE_lib_override_library_status_check_local(struct Main *bmain, struct ID *local);
bool BKE_lib_override_library_status_check_reference(struct Main *bmain, struct ID *local);
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 5b75b8ac181..6a206fc46d9 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -559,6 +559,46 @@ void BKE_lib_override_library_property_operation_delete(
}
/**
+ * Validate that required data for a given operation are available.
+ */
+bool BKE_lib_override_library_property_operation_operands_validate(
+ struct IDOverrideLibraryPropertyOperation *override_property_operation,
+ struct PointerRNA *ptr_dst,
+ struct PointerRNA *ptr_src,
+ struct PointerRNA *ptr_storage,
+ struct PropertyRNA *prop_dst,
+ struct PropertyRNA *prop_src,
+ struct PropertyRNA *prop_storage)
+{
+ switch (override_property_operation->operation) {
+ case IDOVERRIDE_LIBRARY_OP_NOOP:
+ return true;
+ case IDOVERRIDE_LIBRARY_OP_ADD:
+ ATTR_FALLTHROUGH;
+ case IDOVERRIDE_LIBRARY_OP_SUBTRACT:
+ ATTR_FALLTHROUGH;
+ case IDOVERRIDE_LIBRARY_OP_MULTIPLY:
+ if (ptr_storage == NULL || ptr_storage->data == NULL || prop_storage == NULL) {
+ BLI_assert(!"Missing data to apply differential override operation.");
+ return false;
+ }
+ ATTR_FALLTHROUGH;
+ case IDOVERRIDE_LIBRARY_OP_INSERT_AFTER:
+ ATTR_FALLTHROUGH;
+ case IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE:
+ ATTR_FALLTHROUGH;
+ case IDOVERRIDE_LIBRARY_OP_REPLACE:
+ if ((ptr_dst == NULL || ptr_dst->data == NULL || prop_dst == NULL) ||
+ (ptr_src == NULL || ptr_src->data == NULL || prop_src == NULL)) {
+ BLI_assert(!"Missing data to apply override operation.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
* Check that status of local data-block is still valid against current reference one.
*
* It means that all overridable, but not overridden, properties' local values must be equal to