Page MenuHome

Crash when adding a new scene with empty
Closed, ResolvedPublic


System Information
Windows 10

Blender Version
Broken: Blender 2.8 Alpha 2 70d73ff5007

Short description of error
Blender crashes if you add an empty, then create a new scene. The crash occurs in buttons_context_compute when CTX_data_active_object returns null.

Exact steps for others to reproduce the error

  1. Create a new scene
  2. Delete the cube
  3. Shift A and add an empty
  4. Create a new scene

Blender will crash

Event Timeline

I've added a fix for this, I just need to get permissions set up to push it to the repo.

  • a/source/blender/editors/space_buttons/buttons_context.c

+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -647,7 +647,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)

else {
        Object *ob = CTX_data_active_object(C);
  • if (ob->type == OB_GPENCIL) {

+ if (ob && ob->type == OB_GPENCIL) {

        sbuts->dataicon = ICON_GREASEPENCIL;
else {
Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Oct 26 2018, 4:02 PM

Can confirm this fixes the crash.
@Mal Duffin (mal_cando) : for maximum convenience, could you create a diff here?
Regarding commit rights, see

Not sure though if there is a better fix for this [there might be an underlying issue still]

Even with the patch we are still getting an error from UI code:

Traceback (most recent call last):
  File "/scripts/startup/bl_ui/", line 59, in draw
    row.prop(ob, "location")
TypeError: UILayout.prop(): error with argument 1, "data" - does not support a 'None' assignment AnyType type

So something is wrong with the buttons context when adding a "New" scene. We shouldnt actually be getting to this part of the code for a context without active object?
2.79 would have changed to the Scene context BCONTEXT_SCENE (and its relating panels) in Properties Editor automatically when you were in e.g. Object context. 2.8 however doesnt do this, it sticks the object context and its panels -- "Transform" etc.

Might just be a refresh/notifier/messagebus thingie, havent looked deeper (will happily do so if the following want me to)
@Antonio Vazquez (antoniov): you've added the dependency on active object in that part of the code: have an idea?
@Brecht Van Lommel (brecht): does the missing refresh (or whatever cause it actually is) ring a bell?

This special exception for the grease pencil icon should be removed, it seems to work fine without. It's wrong to base the icon on the object type, it is possible to pin just the grease pencil data without an object.

For the refresh issue, there is a problem in the context path computation in buttons_context_compute() and the various functions that it calls. It should not use CTX_data_scene, CTX_data_view_layer and CTX_data_active_object, because that will read from the (previous) path with the old scene. Instead it should use WM_window_get_active_scene and WM_window_get_active_view_layer (and get the active object from that view layer too).

@Brecht Van Lommel (brecht): thanx for the explanation, let me see if I can put that together

The dependency to ob->type was a code I added, but testing now it's not needed as Brecht commented bcause the icon is get above.

@Philipp Oeser (lichtwerk) Do you want I remove this unneeded code?

I have removed the code related to object in commit: bd7cb42f3d4c

D3866 should fix the refresh.
Noticed issues with greasepencil pinning [but will move that to a fresh report...]