From 0796f5a8ed8ed3b90778bcd4b8ec027b5a8ae3f9 Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert@folkertdev.nl>
Date: Sat, 29 Oct 2016 11:23:29 +0200
Subject: [PATCH] Fixes T49855 - Exception when there is no line set

The UI code assumed the existence of an active lineset. Turns out that
the final lineset can be removed (unlike render layers, where there is
always at least one).
---
 render_freestyle_svg.py | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/render_freestyle_svg.py b/render_freestyle_svg.py
index 2d6484b03..6cc2e1b61 100644
--- a/render_freestyle_svg.py
+++ b/render_freestyle_svg.py
@@ -190,19 +190,28 @@ class SVGExporterLinesetPanel(bpy.types.Panel):
         scene = context.scene
         svg = scene.svg_export
         freestyle = scene.render.layers.active.freestyle_settings
-        linestyle = freestyle.linesets.active.linestyle
 
-        layout.active = (svg.use_svg_export and freestyle.mode != 'SCRIPT')
-        row = layout.row()
-        column = row.column()
-        column.prop(linestyle, 'use_export_strokes')
+        try:
+            linestyle = freestyle.linesets.active.linestyle
 
-        column = row.column()
-        column.active = svg.object_fill
-        column.prop(linestyle, 'use_export_fills')
+        except AttributeError:
+            # Linestyles can be removed, so 0 linestyles is possible.
+            # there is nothing to draw in those cases.
+            # see https://developer.blender.org/T49855
+            return
 
-        row = layout.row()
-        row.prop(linestyle, "stroke_color_mode", expand=True)
+        else:
+            layout.active = (svg.use_svg_export and freestyle.mode != 'SCRIPT')
+            row = layout.row()
+            column = row.column()
+            column.prop(linestyle, 'use_export_strokes')
+
+            column = row.column()
+            column.active = svg.object_fill
+            column.prop(linestyle, 'use_export_fills')
+
+            row = layout.row()
+            row.prop(linestyle, "stroke_color_mode", expand=True)
 
 
 class SVGExport(bpy.types.PropertyGroup):
-- 
GitLab