Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/library_query.c
| Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | switch ((ID_Type)GS(id->name)) { | ||||
| CALLBACK_INVOKE(lib->parent, IDWALK_NOP); | CALLBACK_INVOKE(lib->parent, IDWALK_NOP); | ||||
| break; | break; | ||||
| } | } | ||||
| case ID_SCE: | case ID_SCE: | ||||
| { | { | ||||
| Scene *scene = (Scene *) id; | Scene *scene = (Scene *) id; | ||||
| ToolSettings *toolsett = scene->toolsettings; | ToolSettings *toolsett = scene->toolsettings; | ||||
| SceneRenderLayer *srl; | SceneRenderLayer *srl; | ||||
| Base *base; | Base *legacy_base; | ||||
| CALLBACK_INVOKE(scene->camera, IDWALK_NOP); | CALLBACK_INVOKE(scene->camera, IDWALK_NOP); | ||||
| CALLBACK_INVOKE(scene->world, IDWALK_USER); | CALLBACK_INVOKE(scene->world, IDWALK_USER); | ||||
| CALLBACK_INVOKE(scene->set, IDWALK_NOP); | CALLBACK_INVOKE(scene->set, IDWALK_NOP); | ||||
| CALLBACK_INVOKE(scene->clip, IDWALK_USER); | CALLBACK_INVOKE(scene->clip, IDWALK_USER); | ||||
| if (scene->nodetree) { | if (scene->nodetree) { | ||||
| /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ | /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */ | ||||
| library_foreach_ID_as_subdata_link((ID *)scene->nodetree, callback, user_data, flag, &data); | library_foreach_ID_as_subdata_link((ID *)scene->nodetree, callback, user_data, flag, &data); | ||||
| Show All 40 Lines | switch ((ID_Type)GS(id->name)) { | ||||
| CALLBACK_INVOKE(smd->mask_id, IDWALK_USER); | CALLBACK_INVOKE(smd->mask_id, IDWALK_USER); | ||||
| } | } | ||||
| } | } | ||||
| SEQ_END | SEQ_END | ||||
| } | } | ||||
| CALLBACK_INVOKE(scene->gpd, IDWALK_USER); | CALLBACK_INVOKE(scene->gpd, IDWALK_USER); | ||||
| for (base = scene->base.first; base; base = base->next) { | for (legacy_base = scene->base.first; legacy_base; legacy_base = legacy_base->next) { | ||||
| CALLBACK_INVOKE(base->object, IDWALK_USER); | CALLBACK_INVOKE(legacy_base->object, IDWALK_USER); | ||||
| } | } | ||||
| SceneCollection *sc; | SceneCollection *sc; | ||||
| FOREACH_SCENE_COLLECTION(scene, sc) | FOREACH_SCENE_COLLECTION(scene, sc) | ||||
| { | { | ||||
| for (LinkData *link = sc->objects.first; link; link = link->next) { | for (LinkData *link = sc->objects.first; link; link = link->next) { | ||||
| CALLBACK_INVOKE_ID(link->data, IDWALK_USER); | CALLBACK_INVOKE_ID(link->data, IDWALK_USER); | ||||
| } | } | ||||
| for (LinkData *link = sc->filter_objects.first; link; link = link->next) { | for (LinkData *link = sc->filter_objects.first; link; link = link->next) { | ||||
| CALLBACK_INVOKE_ID(link->data, IDWALK_USER); | CALLBACK_INVOKE_ID(link->data, IDWALK_USER); | ||||
mont29: This is not going to work at all.
If you check `CALLBACK_INVOKE` and further macros down the… | |||||
| } | } | ||||
| } | } | ||||
| FOREACH_SCENE_COLLECTION_END | FOREACH_SCENE_COLLECTION_END | ||||
| SceneLayer *sl; | SceneLayer *sl; | ||||
| for (sl = scene->render_layers.first; sl; sl = sl->next) { | for (sl = scene->render_layers.first; sl; sl = sl->next) { | ||||
| for (ObjectBase *ob_base = sl->object_bases.first; ob_base; ob_base = ob_base->next) { | for (ObjectBase *base = sl->object_bases.first; base; base = base->next) { | ||||
| CALLBACK_INVOKE(ob_base->object, IDWALK_NOP); | CALLBACK_INVOKE(base->object, IDWALK_NOP); | ||||
| } | } | ||||
| } | } | ||||
| for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { | for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { | ||||
| CALLBACK_INVOKE(marker->camera, IDWALK_NOP); | CALLBACK_INVOKE(marker->camera, IDWALK_NOP); | ||||
| } | } | ||||
| if (toolsett) { | if (toolsett) { | ||||
| ▲ Show 20 Lines • Show All 868 Lines • Show Last 20 Lines | |||||
This is not going to work at all.
If you check CALLBACK_INVOKE and further macros down the path, up till callback definition itself (LibraryIDLinkCallback), you'll notice we are passing a pointer to pointer here (ID **id_pointer), so you absolutely cannot use a temp local pointer for this, and you absolutely cannot use FOREACH_SCENE_OBJECT either.
What you need to do instead is looping over *all* collections in the scene and pass their object pointers to the callback. And if a same collection can be used as sub-collection of several others, (not sure design allows that or not?), then you'll have to add a way (a flag probably) to prevent a same collection to be handled more than once.
The whole point of this libquery BKE_library_foreach_ID_link function is to be able to edit the pointers themselves, not only the data-blocks they point to.