[Bf-extensions-cvs] [a927d3e1] blender-v2.91-release: glTF importer: Fix T82189 avoid traceback on non valid file with empty primitive tab

Julien Duroure noreply at git.blender.org
Wed Oct 28 18:29:44 CET 2020


Commit: a927d3e1bca8a9d2c5e16932e32866954435cc7b
Author: Julien Duroure
Date:   Wed Oct 28 18:28:36 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rBAa927d3e1bca8a9d2c5e16932e32866954435cc7b

glTF importer: Fix T82189 avoid traceback on non valid file with empty primitive tab

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_mesh.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 03180b3f..75b5a497 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 4, 38),
+    "version": (1, 4, 39),
     'blender': (2, 91, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index 34e979b9..09ec325b 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -91,9 +91,10 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
         num_cols = max(i, num_cols)
 
     num_shapekeys = 0
-    for morph_i, _ in enumerate(pymesh.primitives[0].targets or []):
-        if pymesh.shapekey_names[morph_i] is not None:
-            num_shapekeys += 1
+    if len(pymesh.primitives) > 0: # Empty primitive tab is not allowed, but some invalid files...
+        for morph_i, _ in enumerate(pymesh.primitives[0].targets or []):
+            if pymesh.shapekey_names[morph_i] is not None:
+                num_shapekeys += 1
 
     # -------------
     # We'll process all the primitives gathering arrays to feed into the



More information about the Bf-extensions-cvs mailing list