Freestyle SVG Export: Exception when render layer does not have a freestyle line set #49855

Closed
opened 2016-10-27 07:05:23 +02:00 by Andrew Wright · 9 comments

System Information
Windows 7 Professional SP1
NVIDIA GTX 960

Blender Version
Broken: (example: 2.78 4bble22

When the freestyle SVG export addon is enabled and there are no freestyle line sets but freestyle is enabled the SVGExporterLinesetPanel will query the active freestyle line style and cause and attribute error.
Should this be wrapped with a Try/Except, hasattr or poll function to prevent blender from attempting to access freestyle line styles when they do not currently exist?
Included below is a stack trace of the error as it occurred on my machine.

CRITICAL | 2016-10-27 15:34:12 | 823 | bv: 2.78 (sub 0) |  Uncaught exception
Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\addons\render_freestyle_svg.py", line 193, in draw
    linestyle = freestyle.linesets.active.linestyle
AttributeError: 'NoneType' object has no attribute 'linestyle'

Exact steps for others to reproduce the error

  1. Load default startup file
  2. Enable the Freestyle SVG Export Add on
  3. Enable Freestyle on the render properties panel
  4. Delete the default lineset from the Freestyle Line sets panel in the Render layers properties tab
  5. The above exception should occur
**System Information** Windows 7 Professional SP1 NVIDIA GTX 960 **Blender Version** Broken: (example: 2.78 4bble22 When the freestyle SVG export addon is enabled and there are no freestyle line sets but freestyle is enabled the SVGExporterLinesetPanel will query the active freestyle line style and cause and attribute error. Should this be wrapped with a Try/Except, hasattr or poll function to prevent blender from attempting to access freestyle line styles when they do not currently exist? Included below is a stack trace of the error as it occurred on my machine. ``` CRITICAL | 2016-10-27 15:34:12 | 823 | bv: 2.78 (sub 0) | Uncaught exception Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\addons\render_freestyle_svg.py", line 193, in draw linestyle = freestyle.linesets.active.linestyle AttributeError: 'NoneType' object has no attribute 'linestyle' ``` **Exact steps for others to reproduce the error** 1. Load default startup file 2. Enable the Freestyle SVG Export Add on 3. Enable Freestyle on the render properties panel 4. Delete the default lineset from the Freestyle Line sets panel in the Render layers properties tab 5. The above exception should occur
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @awrigh502

Added subscriber: @awrigh502

Added subscribers: @flokkievids, @VukGardasevic

Added subscribers: @flokkievids, @VukGardasevic
Folkert de Vries was assigned by Vuk Gardašević 2016-10-29 06:15:36 +02:00

I can confirm the issue. The UI code doesn't have a check for lineset existence, resulting in firing up errors in the console.
@flokkievids Would you mind take a look? Thanks.

I can confirm the issue. The UI code doesn't have a check for lineset existence, resulting in firing up errors in the console. @flokkievids Would you mind take a look? Thanks.

This issue was referenced by 0796f5a8ed

This issue was referenced by 0796f5a8ed8ed3b90778bcd4b8ec027b5a8ae3f9

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Added subscriber: @kjym3

Added subscriber: @kjym3

This issue has been resolved. Thanks for the bug report!

@kjym3: The core issue here is that its possible to have 0 linesets whilst Freestyle is enabled. In contrast
a scene always has at least one render layer: it's impossible to remove the final one.

I don't see how having 0 linesets would be useful and would propose to make that impossible. Any thoughts?

This issue has been resolved. Thanks for the bug report! @kjym3: The core issue here is that its possible to have 0 linesets whilst Freestyle is enabled. In contrast a scene always has at least one render layer: it's impossible to remove the final one. I don't see how having 0 linesets would be useful and would propose to make that impossible. Any thoughts?

If I remember correctly, I didn't even consider the possibility of imposing the constraint that there must be at least one lineset. It is easy to check if there's a lineset, and I was not aware of negative effects due to an empty set of linesets.

Making it impossible to have an empty set of linesets is not a good idea, because the data structure representing the set of linesets is part of a scene render layer. The memory for the set of linesets is hence allocated when a new scene render layer is created, so that the set of linesets needs to be populated by a default lineset, which in turn triggers the allocation of a new line style data block, no matter whether Freestyle is enabled or not. Having ten render layers would then imply ten line style data blocks in a .blend file even when you don't use Freestyle, which is unlikely acceptable from non-Freestyle users' perspective.

As to 0796f5a8ed, you can simply test if freestyle.linesets.active is None and return from the draw() function if that is the case. You don't need to rely on a try-except clause.

If I remember correctly, I didn't even consider the possibility of imposing the constraint that there must be at least one lineset. It is easy to check if there's a lineset, and I was not aware of negative effects due to an empty set of linesets. Making it impossible to have an empty set of linesets is not a good idea, because the data structure representing the set of linesets is part of a scene render layer. The memory for the set of linesets is hence allocated when a new scene render layer is created, so that the set of linesets needs to be populated by a default lineset, which in turn triggers the allocation of a new line style data block, no matter whether Freestyle is enabled or not. Having ten render layers would then imply ten line style data blocks in a .blend file even when you don't use Freestyle, which is unlikely acceptable from non-Freestyle users' perspective. As to 0796f5a8ed, you can simply test if freestyle.linesets.active is None and return from the draw() function if that is the case. You don't need to rely on a try-except clause.
Sign in to join this conversation.
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-addons#49855
No description provided.