[Bf-blender-cvs] [2223d63c58c] blender2.8: Refactor static override code to pass Main around.

Bastien Montagne noreply at git.blender.org
Fri Jun 29 12:48:24 CEST 2018


Commit: 2223d63c58c9a2125fb4a2e6ee1c780c781a95bb
Author: Bastien Montagne
Date:   Fri Jun 29 12:46:54 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2223d63c58c9a2125fb4a2e6ee1c780c781a95bb

Refactor static override code to pass Main around.

Access to main database is actually rarely needed, but some custom
'apply' functions do need it (like Collections' overriding of objects or
children collections).

===================================================================

M	source/blender/blenkernel/BKE_library_override.h
M	source/blender/blenkernel/intern/library_override.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/object/object_relations.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_group.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_internal_types.h
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/blender/makesrna/intern/rna_rna.c
M	source/blender/windowmanager/intern/wm_keymap.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h
index 6f32d565562..4792d203d23 100644
--- a/source/blender/blenkernel/BKE_library_override.h
+++ b/source/blender/blenkernel/BKE_library_override.h
@@ -62,10 +62,10 @@ struct IDOverrideStaticPropertyOperation *BKE_override_static_property_operation
 void BKE_override_static_property_operation_delete(
         struct IDOverrideStaticProperty *override_property, struct IDOverrideStaticPropertyOperation *override_property_operation);
 
-bool BKE_override_static_status_check_local(struct ID *local);
-bool BKE_override_static_status_check_reference(struct ID *local);
+bool BKE_override_static_status_check_local(struct Main *bmain, struct ID *local);
+bool BKE_override_static_status_check_reference(struct Main *bmain, struct ID *local);
 
-bool BKE_override_static_operations_create(struct ID *local, const bool force_auto);
+bool BKE_override_static_operations_create(struct Main *bmain, struct ID *local, const bool force_auto);
 void BKE_main_override_static_operations_create(struct Main *bmain, const bool force_auto);
 
 void BKE_override_static_update(struct Main *bmain, struct ID *local);
@@ -78,7 +78,8 @@ void BKE_main_override_static_update(struct Main *bmain);
 typedef struct Main OverrideStaticStorage;
 
 OverrideStaticStorage *BKE_override_static_operations_store_initialize(void);
-struct ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_storage, struct ID *local);
+struct ID *BKE_override_static_operations_store_start(
+        struct Main *bmain, OverrideStaticStorage *override_storage, struct ID *local);
 void BKE_override_static_operations_store_end(OverrideStaticStorage *override_storage, struct ID *local);
 void BKE_override_static_operations_store_finalize(OverrideStaticStorage *override_storage);
 
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 31e621b236f..150092392b4 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -439,7 +439,7 @@ void BKE_override_static_property_operation_delete(
  * (of IDOverridePropertyOperation) has to be added.
  *
  * \return true if status is OK, false otherwise. */
-bool BKE_override_static_status_check_local(ID *local)
+bool BKE_override_static_status_check_local(Main *bmain, ID *local)
 {
 	BLI_assert(local->override_static != NULL);
 
@@ -459,6 +459,7 @@ bool BKE_override_static_status_check_local(ID *local)
 	RNA_id_pointer_create(reference, &rnaptr_reference);
 
 	if (!RNA_struct_override_matches(
+	        bmain,
 	        &rnaptr_local, &rnaptr_reference, NULL, local->override_static,
 	        RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE | RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
 	{
@@ -478,7 +479,7 @@ bool BKE_override_static_status_check_local(ID *local)
  * This is typically used to detect whether some reference has changed and local needs to be updated against it.
  *
  * \return true if status is OK, false otherwise. */
-bool BKE_override_static_status_check_reference(ID *local)
+bool BKE_override_static_status_check_reference(Main *bmain, ID *local)
 {
 	BLI_assert(local->override_static != NULL);
 
@@ -492,7 +493,7 @@ bool BKE_override_static_status_check_reference(ID *local)
 	BLI_assert(GS(local->name) == GS(reference->name));
 
 	if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) {
-		if (!BKE_override_static_status_check_reference(reference)) {
+		if (!BKE_override_static_status_check_reference(bmain, reference)) {
 			/* If reference is also override of another data-block, and its status is not OK,
 			 * then this override is not OK either.
 			 * Note that this should only happen when reloading libraries... */
@@ -506,6 +507,7 @@ bool BKE_override_static_status_check_reference(ID *local)
 	RNA_id_pointer_create(reference, &rnaptr_reference);
 
 	if (!RNA_struct_override_matches(
+	        bmain,
 	        &rnaptr_local, &rnaptr_reference, NULL, local->override_static,
 	        RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
 	{
@@ -528,7 +530,7 @@ bool BKE_override_static_status_check_reference(ID *local)
  * are much cheaper.
  *
  * \return true if new overriding op was created, or some local data was reset. */
-bool BKE_override_static_operations_create(ID *local, const bool force_auto)
+bool BKE_override_static_operations_create(Main *bmain, ID *local, const bool force_auto)
 {
 	BLI_assert(local->override_static != NULL);
 	const bool is_template = (local->override_static->reference == NULL);
@@ -541,6 +543,7 @@ bool BKE_override_static_operations_create(ID *local, const bool force_auto)
 
 		eRNAOverrideMatchResult report_flags = 0;
 		RNA_struct_override_matches(
+		            bmain,
 		            &rnaptr_local, &rnaptr_reference, NULL, local->override_static,
 		            RNA_OVERRIDE_COMPARE_CREATE | RNA_OVERRIDE_COMPARE_RESTORE, &report_flags);
 		if (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) {
@@ -577,7 +580,7 @@ void BKE_main_override_static_operations_create(Main *bmain, const bool force_au
 			if (force_auto ||
 			    (ID_IS_STATIC_OVERRIDE_AUTO(id) && (id->tag & LIB_TAG_OVERRIDESTATIC_AUTOREFRESH)))
 			{
-				BKE_override_static_operations_create(id, force_auto);
+				BKE_override_static_operations_create(bmain, id, force_auto);
 				id->tag &= ~LIB_TAG_OVERRIDESTATIC_AUTOREFRESH;
 			}
 		}
@@ -625,7 +628,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
 		RNA_id_pointer_create(local->override_static->storage, rnaptr_storage);
 	}
 
-	RNA_struct_override_apply(&rnaptr_dst, &rnaptr_src, rnaptr_storage, local->override_static);
+	RNA_struct_override_apply(bmain, &rnaptr_dst, &rnaptr_src, rnaptr_storage, local->override_static);
 
 	/* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa. So when we'll free tmp_id,
 	 * we'll actually free old, outdated data from local. */
@@ -693,7 +696,7 @@ OverrideStaticStorage *BKE_override_static_operations_store_initialize(void)
  * Generate suitable 'write' data (this only affects differential override operations).
  *
  * Note that \a local ID is no more modified by this call, all extra data are stored in its temp \a storage_id copy. */
-ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_storage, ID *local)
+ID *BKE_override_static_operations_store_start(Main *bmain, OverrideStaticStorage *override_storage, ID *local)
 {
 	BLI_assert(local->override_static != NULL);
 	BLI_assert(override_storage != NULL);
@@ -705,7 +708,7 @@ ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_s
 	}
 
 	/* Forcefully ensure we know about all needed override operations. */
-	BKE_override_static_operations_create(local, false);
+	BKE_override_static_operations_create(bmain, local, false);
 
 	ID *storage_id;
 #ifdef DEBUG_OVERRIDE_TIMEIT
@@ -725,7 +728,9 @@ ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_s
 		RNA_id_pointer_create(local, &rnaptr_final);
 		RNA_id_pointer_create(storage_id, &rnaptr_storage);
 
-		if (!RNA_struct_override_store(&rnaptr_final, &rnaptr_reference, &rnaptr_storage, local->override_static)) {
+		if (!RNA_struct_override_store(
+		        bmain, &rnaptr_final, &rnaptr_reference, &rnaptr_storage, local->override_static))
+		{
 			BKE_libblock_free_ex(override_storage, storage_id, true, false);
 			storage_id = NULL;
 		}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 5402114c8f8..61762b5d7ed 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3840,7 +3840,7 @@ static bool write_file_handle(
 				const bool do_override = !ELEM(override_storage, NULL, bmain) && id->override_static;
 
 				if (do_override) {
-					BKE_override_static_operations_store_start(override_storage, id);
+					BKE_override_static_operations_store_start(bmain, override_storage, id);
 				}
 
 				switch ((ID_Type)GS(id->name)) {
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index aad48d13277..571c1327f78 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -464,6 +464,7 @@ static int override_remove_button_poll(bContext *C)
 
 static int override_remove_button_exec(bContext *C, wmOperator *op)
 {
+	Main *bmain = CTX_data_main(C);
 	PointerRNA ptr, id_refptr, src;
 	PropertyRNA *prop;
 	int index;
@@ -505,7 +506,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op)
 		}
 		BKE_override_static_property_operation_delete(oprop, opop);
 		if (!is_template) {
-			RNA_property_copy(&ptr, &src, prop, index);
+			RNA_property_copy(bmain, &ptr, &src, prop, index);
 		}
 		if (BLI_listbase_is_empty(&oprop->operations)) {
 			BKE_override_static_property_delete(id->override_static, oprop);
@@ -515,7 +516,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op)
 		/* Just remove whole generic override operation of this property. */
 		BKE_override_static_property_delete(id->override_static, oprop);
 		if (!is_template) {
-			RNA_property_copy(&ptr, &src, prop, -1);
+			RNA_property_copy(bmain, &ptr, &src, prop, -1);
 		}
 	}
 
@@ -699,6 +700,7 @@ bool UI_context_copy_to_selected_list(
  */
 static bool copy_to_selected_button(bContext *C, bool all, bool poll)
 {
+	Main *bmain = CTX_data_main(C);
 	PointerRNA ptr, lptr, idptr;
 	PropertyRNA *prop, *lprop;
 	bool success = false;
@@ -747,7 +749,7 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
 								break;
 							}
 							else {
-								if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) {
+								if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
 									RNA_property_update(C, &lptr, prop);
 									success = true;
 								}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index f2e996237cf..8db58b17520 100644
--- a/source/blender

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list