[Bf-blender-cvs] [ae462320b82] readfile-rework-refcount-handling: Better handling of usages of usercount increment in readfile liblink.

Bastien Montagne noreply at git.blender.org
Thu Feb 6 11:03:52 CET 2020


Commit: ae462320b8206de387e81564f560576ee45000bd
Author: Bastien Montagne
Date:   Wed Feb 5 17:52:34 2020 +0100
Branches: readfile-rework-refcount-handling
https://developer.blender.org/rBae462320b8206de387e81564f560576ee45000bd

Better handling of usages of usercount increment in readfile liblink.

Some places could/should still need proper ID refcounting in liblink:
* UI data (spaces) - although this should be strictly 'user one' only...
* Deprectaed data/pointers which are not handled  by libquery code.

Not sure whether IPO pointers really need usercount actually...

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

M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fa5d01c5d08..d9ce2edee43 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1792,7 +1792,7 @@ static void *newlibadr_us(FileData *fd, const void *lib, const void *adr)
 {
   ID *id = newlibadr(fd, lib, adr);
 
-  /* id_us_plus_no_lib(id); */
+  id_us_plus_no_lib(id);
 
   return id;
 }
@@ -1808,7 +1808,7 @@ static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr)
 {
   ID *id = newlibadr(fd, lib, adr);
 
-  /* id_us_ensure_real(id); */
+  id_us_ensure_real(id);
 
   return id;
 }
@@ -2555,7 +2555,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
   switch (prop->type) {
     case IDP_ID: /* PointerProperty */
     {
-      void *newaddr = newlibadr_us(fd, NULL, IDP_Id(prop));
+      void *newaddr = newlibadr(fd, NULL, IDP_Id(prop));
       if (IDP_Id(prop) && !newaddr && G.debug) {
         printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
       }
@@ -2625,8 +2625,8 @@ static void lib_link_id(FileData *fd, Main *UNUSED(bmain), ID *id)
   }
 
   if (id->override_library) {
-    id->override_library->reference = newlibadr_us(fd, id->lib, id->override_library->reference);
-    id->override_library->storage = newlibadr_us(fd, id->lib, id->override_library->storage);
+    id->override_library->reference = newlibadr(fd, id->lib, id->override_library->reference);
+    id->override_library->storage = newlibadr(fd, id->lib, id->override_library->storage);
   }
 }
 
@@ -2731,16 +2731,16 @@ static void direct_link_curveprofile(FileData *fd, CurveProfile *profile)
 static void lib_link_brush(FileData *fd, Main *UNUSED(bmain), Brush *brush)
 {
   /* brush->(mask_)mtex.obj is ignored on purpose? */
-  brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex);
-  brush->mask_mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mask_mtex.tex);
+  brush->mtex.tex = newlibadr(fd, brush->id.lib, brush->mtex.tex);
+  brush->mask_mtex.tex = newlibadr(fd, brush->id.lib, brush->mask_mtex.tex);
   brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image);
   brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
-  brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
+  brush->paint_curve = newlibadr(fd, brush->id.lib, brush->paint_curve);
 
   /* link default grease pencil palette */
   if (brush->gpencil_settings != NULL) {
     if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
-      brush->gpencil_settings->material = newlibadr_us(
+      brush->gpencil_settings->material = newlibadr(
           fd, brush->id.lib, brush->gpencil_settings->material);
 
       if (!brush->gpencil_settings->material) {
@@ -2882,7 +2882,7 @@ static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
 
   for (strip = striplist->first; strip; strip = strip->next) {
     strip->object = newlibadr(fd, id->lib, strip->object);
-    strip->act = newlibadr_us(fd, id->lib, strip->act);
+    strip->act = newlibadr(fd, id->lib, strip->act);
     strip->ipo = newlibadr(fd, id->lib, strip->ipo);
     for (amod = strip->modifiers.first; amod; amod = amod->next) {
       amod->ob = newlibadr(fd, id->lib, amod->ob);
@@ -3127,7 +3127,7 @@ static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
     lib_link_fcurves(fd, id, &strip->fcurves);
 
     /* reassign the counted-reference to action */
-    strip->act = newlibadr_us(fd, id->lib, strip->act);
+    strip->act = newlibadr(fd, id->lib, strip->act);
 
     /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
     if ((strip->act) && (strip->act->idroot == 0)) {
@@ -3224,8 +3224,8 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
   }
 
   /* link action data */
-  adt->action = newlibadr_us(fd, id->lib, adt->action);
-  adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact);
+  adt->action = newlibadr(fd, id->lib, adt->action);
+  adt->tmpact = newlibadr(fd, id->lib, adt->tmpact);
 
   /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
   if ((adt->action) && (adt->action->idroot == 0)) {
@@ -3311,7 +3311,7 @@ static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace)
   id_us_ensure_real(id);
 
   for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
-    layout->screen = newlibadr_us(fd, id->lib, layout->screen);
+    layout->screen = newlibadr(fd, id->lib, layout->screen);
 
     layout_next = layout->next;
     if (layout->screen) {
@@ -3385,14 +3385,14 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
 {
   ntree->id.lib = lib;
 
-  ntree->gpd = newlibadr_us(fd, lib, ntree->gpd);
+  ntree->gpd = newlibadr(fd, lib, ntree->gpd);
 
   for (bNode *node = ntree->nodes.first; node; node = node->next) {
     /* Link ID Properties -- and copy this comment EXACTLY for easy finding
      * of library blocks that implement this.*/
     IDP_LibLinkProperty(node->prop, fd);
 
-    node->id = newlibadr_us(fd, lib, node->id);
+    node->id = newlibadr(fd, lib, node->id);
 
     for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
       IDP_LibLinkProperty(sock->prop, fd);
@@ -3627,7 +3627,7 @@ static void lib_link_constraint_cb(bConstraint *UNUSED(con),
   /* for reference types, we need to increment the usercounts on load... */
   if (is_reference) {
     /* reference type - with usercount */
-    *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin);
+    *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin);
   }
   else {
     /* target type - no usercount needed */
@@ -3759,7 +3759,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
 
     IDP_LibLinkProperty(pchan->prop, fd);
 
-    pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
+    pchan->custom = newlibadr(fd, arm->id.lib, pchan->custom);
     if (UNLIKELY(pchan->bone == NULL)) {
       rebuild = true;
     }
@@ -3850,8 +3850,8 @@ static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca)
   ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object);
 
   for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
-    bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima);
-    bgpic->clip = newlibadr_us(fd, ca->id.lib, bgpic->clip);
+    bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima);
+    bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip);
   }
 }
 
@@ -3985,7 +3985,7 @@ static void direct_link_key(FileData *fd, Key *key)
 static void lib_link_mball(FileData *fd, Main *UNUSED(bmain), MetaBall *mb)
 {
   for (int a = 0; a < mb->totcol; a++) {
-    mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]);
+    mb->mat[a] = newlibadr(fd, mb->id.lib, mb->mat[a]);
   }
 
   mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo);  // XXX deprecated - old animation system
@@ -4187,19 +4187,19 @@ static void direct_link_image(FileData *fd, Image *ima)
 static void lib_link_curve(FileData *fd, Main *UNUSED(bmain), Curve *cu)
 {
   for (int a = 0; a < cu->totcol; a++) {
-    cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]);
+    cu->mat[a] = newlibadr(fd, cu->id.lib, cu->mat[a]);
   }
 
   cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj);
   cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
   cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
-  cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
-  cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
-  cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
-  cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
+  cu->vfont = newlibadr(fd, cu->id.lib, cu->vfont);
+  cu->vfontb = newlibadr(fd, cu->id.lib, cu->vfontb);
+  cu->vfonti = newlibadr(fd, cu->id.lib, cu->vfonti);
+  cu->vfontbi = newlibadr(fd, cu->id.lib, cu->vfontbi);
 
   cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo);  // XXX deprecated - old animation system
-  cu->key = newlibadr_us(fd, cu->id.lib, cu->key);
+  cu->key = newlibadr(fd, cu->id.lib, cu->key);
 }
 
 static void switch_endian_knots(Nurb *nu)
@@ -4280,7 +4280,7 @@ static void direct_link_curve(FileData *fd, Curve *cu)
 
 static void lib_link_texture(FileData *fd, Main *bmain, Tex *tex)
 {
-  tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
+  tex->ima = newlibadr(fd, tex->id.lib, tex->ima);
   tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo);  // XXX deprecated - old animation system
 
   if (tex->nodetree) {
@@ -4327,10 +4327,10 @@ static void lib_link_material(FileData *fd, Main *bmain, Material *ma)
   if (ma->gp_style != NULL) {
     MaterialGPencilStyle *gp_style = ma->gp_style;
     if (gp_style->sima != NULL) {
-      gp_style->sima = newlibadr_us(fd, ma->id.lib, gp_style->sima);
+      gp_style->sima = newlibadr(fd, ma->id.lib, gp_style->sima);
     }
     if (gp_style->ima != NULL) {
-      gp_style->ima = newlibadr_us(fd, ma->id.lib, gp_style->ima);
+      gp_style->ima = newlibadr(fd, ma->id.lib, gp_style->ima);
     }
   }
 }
@@ -4449,7 +4449,7 @@ static void direct_link_pointcache_list(FileData *fd,
 static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
 {
   if (pd && pd->tex) {
-    pd->tex = newlibadr_us(fd, id->lib, pd->tex);
+    pd->tex = newlibadr(fd, id->lib, pd->tex);
   }
   if (pd && pd->f_source) {
     pd->f_source = newlibadr(fd, id->lib, pd->f_source);
@@ -4461,7 +4461,7 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl
   part->ipo = newlibadr_us(fd, part->id.lib, part->ipo);  // XXX deprecated - old animation system
 
   part->instance_object = newlibadr(fd, part->id.lib, part->instance_object);
-  part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection);
+  part->instance_collection = newlibadr(fd, part->id.lib, part->instance_collection);
   part->force_group = newlibadr(fd, part->id.lib, part->force_group);
   part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob);
   part->collision_group = newlibadr(fd, part->id.lib, part->collision_group);
@@ -4511,7 +4511,7 @@ static void lib_link_particlese

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list