Fix/cleanup BKE libquery's ID looper.
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 16 Jun 2016 19:09:01 +0000 (21:09 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 16 Jun 2016 19:12:12 +0000 (21:12 +0200)
Some area were still not in sync with readfile.c, now should be better.

Note that readfile.c has been used as référence here re us refcounting,
not sure how accurate it is, time will say :|

source/blender/blenkernel/intern/library_query.c
source/blender/blenloader/intern/readfile.c

index d29d219160243ad511079c5a22e1b67ba13415e5..4fe408e755a5b9ca075b491312e3ef8e7a917e4e 100644 (file)
@@ -227,6 +227,14 @@ static void library_foreach_mtex(LibraryForeachIDData *data, MTex *mtex)
        FOREACH_FINALIZE_VOID;
 }
 
+static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint)
+{
+       FOREACH_CALLBACK_INVOKE(data, paint->brush, IDWALK_USER);
+       FOREACH_CALLBACK_INVOKE(data, paint->palette, IDWALK_USER);
+
+       FOREACH_FINALIZE_VOID;
+}
+
 
 /**
  * Loop over all of the ID's this datablock links to.
@@ -278,7 +286,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                CALLBACK_INVOKE(scene->camera, IDWALK_NOP);
                                CALLBACK_INVOKE(scene->world, IDWALK_USER);
                                CALLBACK_INVOKE(scene->set, IDWALK_NOP);
-                               CALLBACK_INVOKE(scene->clip, IDWALK_NOP);
+                               CALLBACK_INVOKE(scene->clip, IDWALK_USER);
                                CALLBACK_INVOKE(scene->nodetree, IDWALK_NOP);
                                /* DO NOT handle scene->basact here, it's doubling with the loop over whole scene->base later,
                                 * since basact is just a pointer to one of those items. */
@@ -318,6 +326,9 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                                CALLBACK_INVOKE(seq->clip, IDWALK_USER);
                                                CALLBACK_INVOKE(seq->mask, IDWALK_USER);
                                                CALLBACK_INVOKE(seq->sound, IDWALK_USER);
+                                               for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
+                                                       CALLBACK_INVOKE(smd->mask_id, IDWALK_USER);
+                                               }
                                        }
                                        SEQ_END
                                }
@@ -330,28 +341,28 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 
                                if (toolsett) {
                                        CALLBACK_INVOKE(toolsett->skgen_template, IDWALK_NOP);
+
                                        CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_NOP);
                                        CALLBACK_INVOKE(toolsett->particle.object, IDWALK_NOP);
                                        CALLBACK_INVOKE(toolsett->particle.shape_object, IDWALK_NOP);
-                                       CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_NOP);
-                                       CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_NOP);
-                                       CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_NOP);
+
+                                       library_foreach_paint(&data, &toolsett->imapaint.paint);
+                                       CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_USER);
+                                       CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_USER);
+                                       CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_USER);
+
                                        if (toolsett->vpaint) {
-                                               CALLBACK_INVOKE(toolsett->vpaint->paint.brush, IDWALK_NOP);
-                                               CALLBACK_INVOKE(toolsett->vpaint->paint.palette, IDWALK_NOP);
+                                               library_foreach_paint(&data, &toolsett->vpaint->paint);
                                        }
                                        if (toolsett->wpaint) {
-                                               CALLBACK_INVOKE(toolsett->wpaint->paint.brush, IDWALK_NOP);
-                                               CALLBACK_INVOKE(toolsett->wpaint->paint.palette, IDWALK_NOP);
+                                               library_foreach_paint(&data, &toolsett->wpaint->paint);
                                        }
                                        if (toolsett->sculpt) {
-                                               CALLBACK_INVOKE(toolsett->sculpt->paint.brush, IDWALK_NOP);
-                                               CALLBACK_INVOKE(toolsett->sculpt->paint.palette, IDWALK_NOP);
+                                               library_foreach_paint(&data, &toolsett->sculpt->paint);
                                                CALLBACK_INVOKE(toolsett->sculpt->gravity_object, IDWALK_NOP);
                                        }
                                        if (toolsett->uvsculpt) {
-                                               CALLBACK_INVOKE(toolsett->uvsculpt->paint.brush, IDWALK_NOP);
-                                               CALLBACK_INVOKE(toolsett->uvsculpt->paint.palette, IDWALK_NOP);
+                                               library_foreach_paint(&data, &toolsett->uvsculpt->paint);
                                        }
                                }
 
@@ -398,6 +409,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                        CALLBACK_INVOKE(object->pd->tex, IDWALK_USER);
                                        CALLBACK_INVOKE(object->pd->f_source, IDWALK_NOP);
                                }
+                               /* Note that ob->effect is deprecated, so no need to handle it here. */
 
                                if (object->pose) {
                                        bPoseChannel *pchan;
@@ -608,6 +620,15 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                        CALLBACK_INVOKE(psett->effector_weights->group, IDWALK_NOP);
                                }
 
+                               if (psett->pd) {
+                                       CALLBACK_INVOKE(psett->pd->tex, IDWALK_USER);
+                                       CALLBACK_INVOKE(psett->pd->f_source, IDWALK_NOP);
+                               }
+                               if (psett->pd2) {
+                                       CALLBACK_INVOKE(psett->pd2->tex, IDWALK_USER);
+                                       CALLBACK_INVOKE(psett->pd2->f_source, IDWALK_NOP);
+                               }
+
                                if (psett->boids) {
                                        BoidState *state;
                                        BoidRule *rule;
@@ -625,7 +646,6 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                                }
                                        }
                                }
-
                                break;
                        }
 
@@ -634,16 +654,23 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
                                MovieClip *clip = (MovieClip *) id;
                                MovieTracking *tracking = &clip->tracking;
                                MovieTrackingObject *object;
+                               MovieTrackingTrack *track;
+                               MovieTrackingPlaneTrack *plane_track;
 
                                CALLBACK_INVOKE(clip->gpd, IDWALK_USER);
-                               for (object = tracking->objects.first; object; object = object->next) {
-                                       ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
-                                       MovieTrackingTrack *track;
 
-                                       for (track = tracksbase->first; track; track = track->next) {
+                               for (track = tracking->tracks.first; track; track = track->next) {
+                                       CALLBACK_INVOKE(track->gpd, IDWALK_USER);
+                               }
+                               for (object = tracking->objects.first; object; object = object->next) {
+                                       for (track = object->tracks.first; track; track = track->next) {
                                                CALLBACK_INVOKE(track->gpd, IDWALK_USER);
                                        }
                                }
+
+                               for (plane_track = tracking->plane_tracks.first; plane_track; plane_track = plane_track->next) {
+                                       CALLBACK_INVOKE(plane_track->image, IDWALK_USER);
+                               }
                                break;
                        }
 
index 888e3aabfda622c1ab96a585a02ec60a03f7fff4..b11f30938500a8e19646f34fb9d081d089570dc6 100644 (file)
@@ -5619,7 +5619,6 @@ static void lib_link_scene(FileData *fd, Main *main)
                        for (base = sce->base.first; base; base = next) {
                                next = base->next;
                                
-                               /* base->object= newlibadr_us(fd, sce->id.lib, base->object); */
                                base->object = newlibadr_us(fd, sce->id.lib, base->object);
                                
                                if (base->object == NULL) {