Fix (unreported) crash when making object single user in some cases.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 26 Mar 2019 13:39:43 +0000 (14:39 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 26 Mar 2019 13:41:37 +0000 (14:41 +0100)
Issue would happen in case affected object is linked to collections that
are shared between different scenes' ViewLayers. When switching back to
another scene after making single user, you'd get immediate crash.

source/blender/editors/object/object_relations.c

index 777770e5812a605ada8f49bf5e497b30b369f258..1f89da51d1754475797e6904086022accef4e50d 100644 (file)
@@ -1670,9 +1670,14 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
 
        /* active camera */
        ID_NEW_REMAP(scene->camera);
-       if (v3d) ID_NEW_REMAP(v3d->camera);
+       if (v3d) {
+               ID_NEW_REMAP(v3d->camera);
+       }
 
-       BKE_scene_collection_sync(scene);
+       /* Making single user may affect other scenes if they share with current one some collections in their ViewLayer. */
+       for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
+               BKE_scene_collection_sync(sce);
+       }
 }
 
 /* not an especially efficient function, only added so the single user