[Bf-blender-cvs] [4ec2bdbbda0] master: Cleanup: Add comment about 'make_local' callback of Brush doing bad thing.

Bastien Montagne noreply at git.blender.org
Thu Sep 16 14:31:08 CEST 2021


Commit: 4ec2bdbbda05f7460913b65b5b99621021f7f480
Author: Bastien Montagne
Date:   Thu Sep 16 12:37:19 2021 +0200
Branches: master
https://developer.blender.org/rB4ec2bdbbda05f7460913b65b5b99621021f7f480

Cleanup: Add comment about 'make_local' callback of Brush doing bad thing.

Callbacks in IDTypeInfo should never affect other IDs if they are not
embedded.

We break this rule in some cases, at least each of those should be
clearly commented about and get some security checks to try to avoid
unexpected issues as much as possible.

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

M	source/blender/blenkernel/intern/brush.c

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

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 22d4d00c1c5..d70b941695e 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -161,7 +161,13 @@ static void brush_make_local(Main *bmain, ID *id, const int flags)
 
   if (brush->clone.image) {
     /* Special case: ima always local immediately. Clone image should only have one user anyway. */
+    /* FIXME: Recursive calls affecting other non-embedded IDs are really bad and should be avoided
+     * in IDType callbacks. Higher-level ID management code usually does not expect such things and
+     * does not deal properly with it. */
+    /* NOTE: assert below ensures that the comment above is valid, and that that exception is
+     * acceptable for the time being. */
     BKE_lib_id_make_local(bmain, &brush->clone.image->id, 0);
+    BLI_assert(brush->clone.image->id.lib == NULL && brush->clone.image->id.newid == NULL);
   }
 
   if (!force_local && !force_copy) {



More information about the Bf-blender-cvs mailing list