Fix T58351: Make Single User crashes
This commit is contained in:
parent
dc4c1be1a4
commit
0e76ff18b5
Notes:
blender-bot
2023-02-14 04:50:51 +01:00
Referenced by issue #58351, Make Single User crashes
|
@ -301,17 +301,21 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
|
|||
} \
|
||||
} ((void)0)
|
||||
|
||||
#define FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, _instance) \
|
||||
#define FOREACH_OBJECT_FLAG_BEGIN(scene, _view_layer, _v3d, flag, _instance) \
|
||||
{ \
|
||||
IteratorBeginCb func_begin; \
|
||||
IteratorCb func_next, func_end; \
|
||||
void *data_in; \
|
||||
struct ObjectsVisibleIteratorData data_ = { \
|
||||
.view_layer = _view_layer, \
|
||||
.v3d = _v3d, \
|
||||
}; \
|
||||
\
|
||||
if (flag == SELECT) { \
|
||||
func_begin = &BKE_view_layer_selected_objects_iterator_begin; \
|
||||
func_next = &BKE_view_layer_selected_objects_iterator_next; \
|
||||
func_end = &BKE_view_layer_selected_objects_iterator_end; \
|
||||
data_in = (view_layer); \
|
||||
data_in = &data_; \
|
||||
} \
|
||||
else { \
|
||||
func_begin = BKE_scene_objects_iterator_begin; \
|
||||
|
|
|
@ -1754,7 +1754,7 @@ static void new_id_matar(Main *bmain, Material **matar, const int totcol)
|
|||
}
|
||||
}
|
||||
|
||||
static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
|
||||
static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag)
|
||||
{
|
||||
Lamp *la;
|
||||
Curve *cu;
|
||||
|
@ -1763,7 +1763,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
|
|||
Lattice *lat;
|
||||
ID *id;
|
||||
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, v3d, flag, ob)
|
||||
{
|
||||
if (!ID_IS_LINKED(ob)) {
|
||||
id = ob->data;
|
||||
|
@ -1844,9 +1844,9 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
|
|||
}
|
||||
}
|
||||
|
||||
static void single_object_action_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
|
||||
static void single_object_action_users(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag)
|
||||
{
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, v3d, flag, ob)
|
||||
{
|
||||
if (!ID_IS_LINKED(ob)) {
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
|
@ -1856,12 +1856,12 @@ static void single_object_action_users(Main *bmain, Scene *scene, ViewLayer *vie
|
|||
FOREACH_OBJECT_FLAG_END;
|
||||
}
|
||||
|
||||
static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
|
||||
static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag)
|
||||
{
|
||||
Material *ma, *man;
|
||||
int a;
|
||||
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
|
||||
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, v3d, flag, ob)
|
||||
{
|
||||
if (!ID_IS_LINKED(ob)) {
|
||||
for (a = 1; a <= ob->totcol; a++) {
|
||||
|
@ -1919,8 +1919,8 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
|
|||
single_object_users(bmain, scene, NULL, 0, copy_collections);
|
||||
|
||||
if (full) {
|
||||
single_obdata_users(bmain, scene, NULL, 0);
|
||||
single_object_action_users(bmain, scene, NULL, 0);
|
||||
single_obdata_users(bmain, scene, NULL, NULL, 0);
|
||||
single_object_action_users(bmain, scene, NULL, NULL, 0);
|
||||
single_mat_users_expand(bmain);
|
||||
}
|
||||
|
||||
|
@ -2456,15 +2456,15 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "obdata")) {
|
||||
single_obdata_users(bmain, scene, view_layer, flag);
|
||||
single_obdata_users(bmain, scene, view_layer, v3d, flag);
|
||||
}
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "material")) {
|
||||
single_mat_users(bmain, scene, view_layer, flag);
|
||||
single_mat_users(bmain, scene, view_layer, v3d, flag);
|
||||
}
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "animation")) {
|
||||
single_object_action_users(bmain, scene, view_layer, flag);
|
||||
single_object_action_users(bmain, scene, view_layer, v3d, flag);
|
||||
}
|
||||
|
||||
BKE_main_id_clear_newpoins(bmain);
|
||||
|
|
Loading…
Reference in New Issue