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
path: root/source
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
parente3d575b37651b20b281f431047d97b43c0ce028d (diff)
Refactor/strengthen a bit invalid operands checks when applying an override operation.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_lib_override.h11
-rw-r--r--source/blender/blenkernel/intern/lib_override.c40
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c23
3 files changed, 55 insertions, 19 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
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 199d22ee3dc..32b375fda97 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -481,28 +481,13 @@ static bool rna_property_override_operation_apply(Main *bmain,
const short override_op = opop->operation;
- if (override_op == IDOVERRIDE_LIBRARY_OP_NOOP) {
- return true;
- }
-
- if (ELEM(override_op,
- IDOVERRIDE_LIBRARY_OP_ADD,
- IDOVERRIDE_LIBRARY_OP_SUBTRACT,
- IDOVERRIDE_LIBRARY_OP_MULTIPLY) &&
- !ptr_storage) {
- /* We cannot apply 'diff' override operations without some reference storage.
- * This should typically only happen at read time of .blend file... */
+ if (!BKE_lib_override_library_property_operation_operands_validate(
+ opop, ptr_dst, ptr_src, ptr_storage, prop_dst, prop_src, prop_storage)) {
return false;
}
- if (ELEM(override_op,
- IDOVERRIDE_LIBRARY_OP_ADD,
- IDOVERRIDE_LIBRARY_OP_SUBTRACT,
- IDOVERRIDE_LIBRARY_OP_MULTIPLY) &&
- !prop_storage) {
- /* We cannot apply 'diff' override operations without some reference storage.
- * This should typically only happen at read time of .blend file... */
- return false;
+ if (override_op == IDOVERRIDE_LIBRARY_OP_NOOP) {
+ return true;
}
RNAPropOverrideApply override_apply = NULL;