Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/lib_remap.c
| Show All 20 Lines | |||||
| */ | */ | ||||
| #include "CLG_log.h" | #include "CLG_log.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_windowmanager_types.h" | |||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_lib_query.h" | #include "BKE_lib_query.h" | ||||
| #include "BKE_lib_remap.h" | #include "BKE_lib_remap.h" | ||||
| ▲ Show 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | switch (GS(new_id->name)) { | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| BKE_modifiers_test_object(ob); | BKE_modifiers_test_object(ob); | ||||
| BKE_object_materials_test(bmain, ob, new_id); | BKE_object_materials_test(bmain, ob, new_id); | ||||
| } | } | ||||
| } | } | ||||
| static void libblock_remap_data_postprocess_scene_relink(Main *bmain, | |||||
| Scene *old_scene, | |||||
| Scene *new_scene) | |||||
| { | |||||
| if (new_scene != NULL) { | |||||
| return; | |||||
| } | |||||
| Scene *new_window_scene = NULL; | |||||
| LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { | |||||
| if (scene != old_scene && !ID_IS_LINKED(&scene->id)) { | |||||
| new_window_scene = scene; | |||||
| break; | |||||
mont29: Maybe enforce `new_window_scene` to be local (i.e. explicitly ignoring linked scenes in that… | |||||
| } | |||||
| } | |||||
| /* There has to be at least one local scene. */ | |||||
| BLI_assert(new_window_scene != NULL); | |||||
| wmWindowManager *wm = bmain->wm.first; | |||||
| LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | |||||
| if (win->scene == NULL) { | |||||
| /* Usually WM_window_set_active_scene should be used for that, but it can't be called from | |||||
| * here currently. It seems to work fine in the tested cases. */ | |||||
| win->scene = new_window_scene; | |||||
| } | |||||
| } | |||||
| } | |||||
| static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new_id) | static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new_id) | ||||
| { | { | ||||
| /* Update all group nodes using a node group. */ | /* Update all group nodes using a node group. */ | ||||
| ntreeUpdateAllUsers(bmain, new_id); | ntreeUpdateAllUsers(bmain, new_id); | ||||
| } | } | ||||
| /** | /** | ||||
| * Execute the 'data' part of the remapping (that is, all ID pointers from other ID data-blocks). | * Execute the 'data' part of the remapping (that is, all ID pointers from other ID data-blocks). | ||||
| ▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | switch (GS(old_id->name)) { | ||||
| case ID_PT: | case ID_PT: | ||||
| case ID_VO: | case ID_VO: | ||||
| if (new_id) { /* Only affects us in case obdata was relinked (changed). */ | if (new_id) { /* Only affects us in case obdata was relinked (changed). */ | ||||
| for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { | for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { | ||||
| libblock_remap_data_postprocess_obdata_relink(bmain, ob, new_id); | libblock_remap_data_postprocess_obdata_relink(bmain, ob, new_id); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case ID_SCE: | |||||
| libblock_remap_data_postprocess_scene_relink(bmain, (Scene *)old_id, (Scene *)new_id); | |||||
| break; | |||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| /* Node trees may virtually use any kind of data-block... */ | /* Node trees may virtually use any kind of data-block... */ | ||||
| /* XXX Yuck!!!! nodetree update can do pretty much any thing when talking about py nodes, | /* XXX Yuck!!!! nodetree update can do pretty much any thing when talking about py nodes, | ||||
| * including creating new data-blocks (see T50385), so we need to unlock main here. :( | * including creating new data-blocks (see T50385), so we need to unlock main here. :( | ||||
| * Why can't we have re-entrent locks? */ | * Why can't we have re-entrent locks? */ | ||||
| ▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines | |||||
Maybe enforce new_window_scene to be local (i.e. explicitly ignoring linked scenes in that loop)? Would be by default anyway if there is a local one, due to ordering of IDs in their main lists.