diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-03-13 22:10:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-03-14 14:13:27 +0300 |
commit | e7c3c46e8902a214c12f2cba70790646a6fcfda6 (patch) | |
tree | 9542b3d995303fb73f18b48a10ce5f879c1f661f /source/blender/editors/object/object_relations.c | |
parent | 59aa8d22efa2c7a1dff23211a1f63e2d5bdd0783 (diff) |
Fix make single user crash
How to reproduce the crash:
* Factory startup
* 'u'key (make single user)
It comes with a simple unittest to reproduce the original issue.
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r-- | source/blender/editors/object/object_relations.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5e7e0fb68a3..00c5fdf3cc7 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1632,33 +1632,30 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) static Object *single_object_users_object(Main *bmain, Scene *scene, Object *ob, const bool copy_groups) { - if (!ID_IS_LINKED(ob) && ob->id.us > 1) { - /* base gets copy of object */ - Object *obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); + /* base gets copy of object */ + Object *obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); - if (copy_groups) { - if (ob->flag & OB_FROMGROUP) { - obn->flag |= OB_FROMGROUP; - } - } - else { - /* copy already clears */ + if (copy_groups) { + if (ob->flag & OB_FROMGROUP) { + obn->flag |= OB_FROMGROUP; } - /* remap gpencil parenting */ + } + else { + /* copy already clears */ + } + /* remap gpencil parenting */ - if (scene->gpd) { - bGPdata *gpd = scene->gpd; - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - if (gpl->parent == ob) { - gpl->parent = obn; - } + if (scene->gpd) { + bGPdata *gpd = scene->gpd; + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if (gpl->parent == ob) { + gpl->parent = obn; } } - - id_us_min(&ob->id); - return obn; } - return NULL; + + id_us_min(&ob->id); + return obn; } static void libblock_relink_scene_collection(SceneCollection *sc) @@ -1678,7 +1675,9 @@ static void single_object_users_scene_collection(Main *bmain, Scene *scene, Scen Object *ob = link->data; /* an object may be in more than one collection */ if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) { - link->data = single_object_users_object(bmain, scene, link->data, copy_groups); + if (!ID_IS_LINKED(ob) && ob->id.us > 1) { + link->data = single_object_users_object(bmain, scene, link->data, copy_groups); + } } } |