fix for lightwave object loader
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2008 20:31:11 +0000 (20:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2008 20:31:11 +0000 (20:31 +0000)
release/scripts/lightwave_import.py

index 24e072f018a011315662f3d7a7dbbd39e8a775d4..b59d582d680927d5750651a884845cc83fc82d03 100644 (file)
@@ -656,7 +656,12 @@ def read_clip(lwochunk, dir_part):
 # ima, IMAG, g_IMAG refers to clip dictionary 'ID' entries: refer to blok and surf
        clip_dict = {}
        data = cStringIO.StringIO(lwochunk.read())
-       image_index, = struct.unpack(">L", data.read(4))
+       data_str = data.read(4)
+       if len(data_str) < 4: # can be zero also??? :/
+               # Should not happen but lw can import so we should too
+               return 
+       
+       image_index, = struct.unpack(">L", )
        clip_dict['ID'] = image_index
        i = 4
        while(i < lwochunk.chunksize):
@@ -1634,11 +1639,11 @@ def main():
                return
        
        Blender.Window.FileSelector(read, "Import LWO", '*.lwo')
-       
 
 if __name__=='__main__':
        main()
 
+
 # Cams debugging lwo loader
 """
 TIME= Blender.sys.time()