When Toggling all Layers using the Tilde Key directly after a Scene Switch, the Render Camera is removed
Open, ConfirmedPublic


System Information
Windows 7 x64, Quadro 4000

Blender Version
Broken: 2.77a, 2.78 any build so far

Short description of error
I've made a demo file to test. In this file there are three scenes. If you switch from Scene to Scene.001, and then directly after that hit the Tilde key (which calls bpy.ops.view3d.layers()), the active render camera is removed from the slot.

Exact steps for others to reproduce the error
Open the provided Blend, switch to Scene.001, hit Tilde. The Scene.camera property becomes None:



Related Objects

Sergey Sharybin (sergey) triaged this task as Confirmed priority.EditedSep 27 2016, 11:18 AM

Can confirm the issue, but not sure yet what's going on.

Main reason this happens is because the camera for Scene.001 is coming from a different scene. This is generally supported and I don't see any issues with it, so don't think we should prevent this.

Would propose this fix:

1diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
2index 0713377..d960992 100644
3--- a/source/blender/editors/space_view3d/view3d_header.c
4+++ b/source/blender/editors/space_view3d/view3d_header.c
5@@ -68,8 +68,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
6​ #define B_SEL_EDGE 111
7​ #define B_SEL_FACE 112
9-/* XXX quickly ported across */
10-static void handle_view3d_lock(bContext *C)
12+ * If needed, sync scene with changed 3D view layers and update all 3D views for changed scene data.
13+ */
14+static void view3d_layers_update(bContext *C)
15​ {
16​ Main *bmain = CTX_data_main(C);
17​ Scene *scene = CTX_data_scene(C);
18@@ -81,7 +83,6 @@ static void handle_view3d_lock(bContext *C)
19​ /* copy to scene */
20​ scene->lay = v3d->lay;
21​ scene->layact = v3d->layact;
22- scene->camera = v3d->camera;
24​ /* not through notifier, listener don't have context
25​ * and non-open screens or spaces need to be updated too */
26@@ -170,7 +171,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
27​ }
28​ }
30- if (v3d->scenelock) handle_view3d_lock(C);
31+ if (v3d->scenelock) view3d_layers_update(C);
33​ DAG_on_visible_update(CTX_data_main(C), false);
Really don't see why you'd update scene camera when changing 3D view layers... probably this function used to be called after changing 3D View camera.

@Julian Eisel (Severin) I tried to apply this as a patch today, but it failed for me (didn't find the lines to change). To I need to target a specific commit to make it work?