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.
This commit is contained in:
@@ -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 ***** */
|
||||
|
||||
@@ -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[])
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user