diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-22 13:35:41 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-22 13:35:41 +0300 |
commit | 2fe528424d168f124efca5d94c6b0363be49dbf3 (patch) | |
tree | 04bbd895c10e1e155a90eb53f268b593e6421e96 /source/blender/makesrna/intern | |
parent | 101fd7ec0639c03ab017e90cb46367f50e512cbb (diff) |
Cleanup: remove last G.main from RNA.
Again, we cannot actually get rid of G_MAIN global access here, so in
most case just 'marked' them as valid, and added assert checks to ensure
we do only work with IDs in G_MAIN in those cases.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 15 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 13 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 3 |
9 files changed, 47 insertions, 19 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index d3331e6ca52..b45ddf4dc8b 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -121,7 +121,8 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) { ID *id = (ID *)ptr->data; BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2); - BLI_libblock_ensure_unique_name(G.main, id->name); + BLI_assert(BKE_id_is_in_gobal_main(id)); + BLI_libblock_ensure_unique_name(G_MAIN, id->name); } static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -414,7 +415,9 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig short *totcol = give_totcolp_id(id); Material *mat_id = assign_ptr->id.data; if (totcol && (key >= 0 && key < *totcol)) { - assign_material_id(G.main, id, mat_id, key + 1); + BLI_assert(BKE_id_is_in_gobal_main(id)); + BLI_assert(BKE_id_is_in_gobal_main(&mat_id->id)); + assign_material_id(G_MAIN, id, mat_id, key + 1); return 1; } else { @@ -470,7 +473,8 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl static void rna_Library_filepath_set(PointerRNA *ptr, const char *value) { Library *lib = (Library *)ptr->data; - BKE_library_filepath_set(G.main, lib, value); + BLI_assert(BKE_id_is_in_gobal_main(&lib->id)); + BKE_library_filepath_set(G_MAIN, lib, value); } /* ***** ImagePreview ***** */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index b3b69e9c58a..f0af58d4342 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -315,7 +315,8 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(ebone->name)); BLI_strncpy(oldname, ebone->name, sizeof(ebone->name)); - ED_armature_bone_rename(G.main, arm, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&arm->id)); + ED_armature_bone_rename(G_MAIN, arm, oldname, newname); } static void rna_Bone_name_set(PointerRNA *ptr, const char *value) @@ -328,7 +329,8 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(bone->name)); BLI_strncpy(oldname, bone->name, sizeof(bone->name)); - ED_armature_bone_rename(G.main, arm, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&arm->id)); + ED_armature_bone_rename(G_MAIN, arm, oldname, newname); } static void rna_EditBone_layer_set(PointerRNA *ptr, const int values[]) diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index bab8c18439f..9549eb1de08 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -104,7 +104,8 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) if (value != ima->source) { ima->source = value; - BKE_image_signal(G.main, ima, NULL, IMA_SIGNAL_SRC_CHANGE); + BLI_assert(BKE_id_is_in_gobal_main(&ima->id)); + BKE_image_signal(G_MAIN, ima, NULL, IMA_SIGNAL_SRC_CHANGE); DAG_id_tag_update(&ima->id, 0); } } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 87c9291af8d..11cfdbcaa22 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -381,6 +381,9 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) return; } + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(id)); + if (ob->type == OB_EMPTY) { if (ob->data) { id_us_min((ID *)ob->data); @@ -393,7 +396,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) } } else if (ob->type == OB_MESH) { - BKE_mesh_assign_object(G.main, ob, (Mesh *)id); + BKE_mesh_assign_object(G_MAIN, ob, (Mesh *)id); } else { if (ob->data) { @@ -405,7 +408,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) id_us_plus(id); ob->data = id; - test_object_materials(G.main, ob, id); + test_object_materials(G_MAIN, ob, id); if (GS(id->name) == ID_CU) BKE_curve_type_test(ob); @@ -713,7 +716,9 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->id.data; DAG_id_tag_update(value.data, 0); - assign_material(G.main, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); } static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -885,7 +890,9 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->id.data; int index = (Material **)ptr->data - ob->mat; - assign_material(G.main, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + assign_material(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); } static int rna_MaterialSlot_link_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 294597d957e..4e51f81fd89 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -97,6 +97,7 @@ static const EnumPropertyItem empty_vortex_shape_items[] = { #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" @@ -240,7 +241,8 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); *min = 0; *max = 0; @@ -263,7 +265,8 @@ static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) ListBase pidlist; int num = 0; - BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { @@ -284,7 +287,8 @@ static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int v PTCacheID *pid; ListBase pidlist; - BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { @@ -307,7 +311,8 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, *min = 1; *max = 20; - BKE_ptcache_ids_from_object(G.main, &pidlist, ob, NULL, 0); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 746bb0ceacd..a1a026536cf 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -287,7 +287,9 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(pchan->name)); BLI_strncpy(oldname, pchan->name, sizeof(pchan->name)); - ED_armature_bone_rename(G.main, ob->data, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(ob->data)); + ED_armature_bone_rename(G_MAIN, ob->data, oldname, newname); } static int rna_PoseChannel_has_ik_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 2e86ceb2617..07a149009ee 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -111,7 +111,7 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) { /* can be NULL on file load, T42619 */ - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 11610c35b34..87f8537df4e 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -218,14 +218,20 @@ static int rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; - return (pset->object && pset->scene && PE_get_current(G.main, pset->scene, pset->object)); + if (pset->object != NULL && pset->scene != NULL) { + BLI_assert(BKE_id_is_in_gobal_main(&pset->object->id)); + BLI_assert(BKE_id_is_in_gobal_main(&pset->scene->id)); + } + return (pset->object && pset->scene && PE_get_current(G_MAIN, pset->scene, pset->object)); } static int rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; if (pset->scene) { - PTCacheEdit *edit = PE_get_current(G.main, pset->scene, pset->object); + BLI_assert(BKE_id_is_in_gobal_main(&pset->scene->id)); + BLI_assert(BKE_id_is_in_gobal_main(&pset->object->id)); + PTCacheEdit *edit = PE_get_current(G_MAIN, pset->scene, pset->object); return (edit && edit->psys); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index c69679185aa..76938bd8971 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -838,7 +838,8 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - ED_space_image_set(G.main, sima, sc->scene, sc->scene->obedit, (Image *)value.data); + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + ED_space_image_set(G_MAIN, sima, sc->scene, sc->scene->obedit, (Image *)value.data); } static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) |