From 2f425cc128b8b709cc1ebf2c96ad372778f4aeda Mon Sep 17 00:00:00 2001
From: Mikhail Rachinskiy <mikhail.rachinskiy@gmail.com>
Date: Wed, 4 Dec 2019 08:46:23 +0400
Subject: [PATCH] STL: fix T72145 crash exporting object without data

---
 io_mesh_stl/blender_utils.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/io_mesh_stl/blender_utils.py b/io_mesh_stl/blender_utils.py
index 8589e1968..97621d112 100644
--- a/io_mesh_stl/blender_utils.py
+++ b/io_mesh_stl/blender_utils.py
@@ -80,7 +80,8 @@ def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False):
     import bpy
 
     # get the editmode data
-    ob.update_from_editmode()
+    if ob.mode == "EDIT":
+        ob.update_from_editmode()
 
     # get the modifiers
     if use_mesh_modifiers:
@@ -94,6 +95,7 @@ def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False):
         mesh = mesh_owner.to_mesh()
     except RuntimeError:
         return
+
     if mesh is None:
         return
 
-- 
GitLab