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-07-23 12:28:29 +0300
committerBastien Montagne <bastien@blender.org>2020-07-23 12:33:24 +0300
commit79440c37acff6c6fbcdd3d4bb7a703820c722929 (patch)
tree739f988f0a344af197c625e6cd33a3a8c048290c
parentfa21ba017989731c97f77b50c2a5ea2ba4b87ad8 (diff)
LibOverride: Store RNA prop type in override properties.
Storing this info will help with dealing with reset operations and the like (as we do not want to reset overrides of ID pointers essentially).
-rw-r--r--source/blender/makesdna/DNA_ID.h5
-rw-r--r--source/blender/makesrna/intern/rna_rna.c64
2 files changed, 40 insertions, 29 deletions
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index f3bde04184b..4ec622574cc 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -206,7 +206,10 @@ typedef struct IDOverrideLibraryProperty {
/** Runtime, tags are common to both IDOverrideProperty and IDOverridePropertyOperation. */
short tag;
- char _pad0[6];
+ char _pad[2];
+
+ /** The property type matching the rna_path. */
+ unsigned int rna_prop_type;
} IDOverrideLibraryProperty;
/* IDOverrideProperty->tag and IDOverridePropertyOperation->tag. */
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index f9f6defb2f1..9f5440be9f8 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -1250,6 +1250,7 @@ static int rna_property_override_diff_propptr(Main *bmain,
IDOverrideLibrary *override,
const char *rna_path,
size_t rna_path_len,
+ const uint property_type,
const char *rna_itemname_a,
const char *rna_itemname_b,
const int rna_itemindex_a,
@@ -1257,6 +1258,8 @@ static int rna_property_override_diff_propptr(Main *bmain,
const int flags,
bool *r_override_changed)
{
+ BLI_assert(ELEM(property_type, PROP_POINTER, PROP_COLLECTION));
+
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 &&
rna_path != NULL;
@@ -1300,6 +1303,13 @@ static int rna_property_override_diff_propptr(Main *bmain,
if (op != NULL) {
BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false);
+ if (created || op->rna_prop_type == 0) {
+ op->rna_prop_type = property_type;
+ }
+ else {
+ BLI_assert(op->rna_prop_type == property_type);
+ }
+
if (created || rna_itemname_a != NULL || rna_itemname_b != NULL ||
rna_itemindex_a != -1 || rna_itemindex_b != -1) {
BKE_lib_override_library_property_operation_get(op,
@@ -1464,7 +1474,11 @@ int rna_property_override_diff_default(Main *bmain,
PROPOVERRIDE_LIBRARY_INSERTION) &&
do_create;
- switch (RNA_property_type(prop_a->rnaprop)) {
+ const uint rna_prop_type = RNA_property_type(prop_a->rnaprop);
+ bool created = false;
+ IDOverrideLibraryProperty *op = NULL;
+
+ switch (rna_prop_type) {
case PROP_BOOLEAN: {
if (len_a) {
bool array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY];
@@ -1482,9 +1496,7 @@ int rna_property_override_diff_default(Main *bmain,
if (do_create && comp != 0) {
/* XXX TODO this will have to be refined to handle array items */
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) {
BKE_lib_override_library_property_operation_get(
@@ -1513,9 +1525,7 @@ int rna_property_override_diff_default(Main *bmain,
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
if (do_create && comp != 0) {
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) { /* If not yet overridden... */
BKE_lib_override_library_property_operation_get(
@@ -1547,9 +1557,7 @@ int rna_property_override_diff_default(Main *bmain,
if (do_create && comp != 0) {
/* XXX TODO this will have to be refined to handle array items */
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) {
BKE_lib_override_library_property_operation_get(
@@ -1578,9 +1586,7 @@ int rna_property_override_diff_default(Main *bmain,
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
if (do_create && comp != 0) {
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) { /* If not yet overridden... */
BKE_lib_override_library_property_operation_get(
@@ -1612,9 +1618,7 @@ int rna_property_override_diff_default(Main *bmain,
if (do_create && comp != 0) {
/* XXX TODO this will have to be refined to handle array items */
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) {
BKE_lib_override_library_property_operation_get(
@@ -1643,9 +1647,7 @@ int rna_property_override_diff_default(Main *bmain,
const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0;
if (do_create && comp != 0) {
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) { /* If not yet overridden... */
BKE_lib_override_library_property_operation_get(
@@ -1666,9 +1668,7 @@ int rna_property_override_diff_default(Main *bmain,
const int comp = value_a != value_b;
if (do_create && comp != 0) {
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) { /* If not yet overridden... */
BKE_lib_override_library_property_operation_get(
@@ -1700,9 +1700,7 @@ int rna_property_override_diff_default(Main *bmain,
const int comp = strcmp(value_a, value_b);
if (do_create && comp != 0) {
- bool created = false;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (op != NULL && created) { /* If not yet overridden... */
BKE_lib_override_library_property_operation_get(
@@ -1740,6 +1738,7 @@ int rna_property_override_diff_default(Main *bmain,
override,
rna_path,
rna_path_len,
+ PROP_POINTER,
NULL,
NULL,
-1,
@@ -1848,9 +1847,7 @@ int rna_property_override_diff_default(Main *bmain,
* pointers), since they do not support removing, only in *some* cases, insertion. We
* also assume then that _a data is the one where things are inserted. */
if (is_valid_for_insertion && use_collection_insertion) {
- bool created;
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
- override, rna_path, &created);
+ op = BKE_lib_override_library_property_get(override, rna_path, &created);
if (is_first_insert) {
/* We need to clean up all possible existing insertion operations,
@@ -1883,6 +1880,7 @@ int rna_property_override_diff_default(Main *bmain,
prev_propname_a,
idx_a - 1);
# endif
+ op = NULL;
}
else if (is_id || is_valid_for_diffing) {
if (equals || do_create) {
@@ -1895,6 +1893,7 @@ int rna_property_override_diff_default(Main *bmain,
override,
rna_path,
rna_path_len,
+ PROP_COLLECTION,
propname_a,
propname_b,
idx_a,
@@ -1963,6 +1962,15 @@ int rna_property_override_diff_default(Main *bmain,
break;
}
+ if (op != NULL) {
+ if (created || op->rna_prop_type == 0) {
+ op->rna_prop_type = rna_prop_type;
+ }
+ else {
+ BLI_assert(op->rna_prop_type == rna_prop_type);
+ }
+ }
+
return 0;
}