Crash when adding a new scene with empty #57390

Closed
opened 2018-10-26 12:46:50 +02:00 by Mal Duffin · 11 comments
Member

System Information
Windows 10

Blender Version
Broken: Blender 2.8 Alpha 2 70d73ff500

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

**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
Author
Member

Added subscriber: @MalDuffin

Added subscriber: @MalDuffin
Author
Member

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 {
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 {
Member

Added subscribers: @antoniov, @brecht, @lichtwerk

Added subscribers: @antoniov, @brecht, @lichtwerk
Member

Can confirm this fixes the crash.
@MalDuffin : for maximum convenience, could you create a diff here ?
Regarding commit rights, see https://wiki.blender.org/wiki/Process/Commit_Rights.

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/properties_object.py", line 59, in draw
    row.prop(ob, "location")
TypeError: UILayout.prop(): error with argument 1, "data" -  Function.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)
@antoniov: you've added the dependency on active object in that part of the code: have an idea?
@brecht: does the missing refresh (or whatever cause it actually is) ring a bell?

Can confirm this fixes the crash. @MalDuffin : for maximum convenience, could you create a diff [here ](https://developer.blender.org/differential/diff/create/)? Regarding commit rights, see https://wiki.blender.org/wiki/Process/Commit_Rights. 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/properties_object.py", line 59, in draw row.prop(ob, "location") TypeError: UILayout.prop(): error with argument 1, "data" - Function.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) @antoniov: you've added the dependency on active object in that part of the code: have an idea? @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).

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).
Philipp Oeser self-assigned this 2018-10-29 15:54:11 +01:00
Member

@brecht: thanx for the explanation, let me see if I can put that together

@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.

@lichtwerk Do you want I remove this unneeded code?

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. @lichtwerk Do you want I remove this unneeded code?

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

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

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

[D3866](https://archive.blender.org/developer/D3866) should fix the refresh. Noticed issues with greasepencil pinning [but will move that to a fresh report...]

This issue was referenced by 36b9ee1277

This issue was referenced by 36b9ee1277519f1ae471afbc0a99e26eee1acbe4

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#57390
No description provided.