From 6972926b66c7bc97bb23f44c0303a66821824fad Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 9 Aug 2016 09:30:23 -1000 Subject: [PATCH] More blender crash fixes --- DataSpec/DNACommon/MAPA.cpp | 5 +++-- DataSpec/DNACommon/MLVL.cpp | 5 +++-- DataSpec/DNAMP1/FRME.cpp | 5 +++-- DataSpec/DNAMP1/MREA.cpp | 5 +++-- DataSpec/DNAMP2/MREA.cpp | 5 +++-- DataSpec/DNAMP3/MREA.cpp | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/DataSpec/DNACommon/MAPA.cpp b/DataSpec/DNACommon/MAPA.cpp index 0c3d489b0..472b53854 100644 --- a/DataSpec/DNACommon/MAPA.cpp +++ b/DataSpec/DNACommon/MAPA.cpp @@ -116,8 +116,9 @@ bool ReadMAPAToBlender(hecl::BlenderConnection& conn, "\n" "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n" + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n" "\n" "def add_triangle(bm, verts):\n" " verts = [bm.verts[vi] for vi in verts]\n" diff --git a/DataSpec/DNACommon/MLVL.cpp b/DataSpec/DNACommon/MLVL.cpp index 2e9d53cfd..1bbb6244f 100644 --- a/DataSpec/DNACommon/MLVL.cpp +++ b/DataSpec/DNACommon/MLVL.cpp @@ -39,8 +39,9 @@ bool ReadMLVLToBlender(hecl::BlenderConnection& conn, "\n" "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n"); + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n"); /* Insert area empties */ int areaIdx = 0; diff --git a/DataSpec/DNAMP1/FRME.cpp b/DataSpec/DNAMP1/FRME.cpp index 4b219ccb9..305c9e740 100644 --- a/DataSpec/DNAMP1/FRME.cpp +++ b/DataSpec/DNAMP1/FRME.cpp @@ -353,8 +353,9 @@ bool FRME::Extract(const SpecBase &dataSpec, "bpy.types.Object.retro_widget_model_draw_flags = bpy.props.EnumProperty(items=model_draw_flags, name='Retro: Model Draw Flags', default='RETRO_ALPHA')\n" "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n" + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n" "\n" "def duplicateObject(copy_obj):\n" " # Create new mesh\n" diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index a5a77dffd..1e8231ac5 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -95,8 +95,9 @@ bool MREA::Extract(const SpecBase& dataSpec, MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n" + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n" "bpy.types.Lamp.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Lamp.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" "bpy.types.Object.retro_disable_enviro_visor = bpy.props.BoolProperty(name='Retro: Disable in Combat/Scan Visor')\n" diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index 8bfff0716..719ce5220 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -227,8 +227,9 @@ bool MREA::Extract(const SpecBase& dataSpec, MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n" + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n" "bpy.types.Lamp.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Lamp.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" "bpy.types.Object.retro_disable_enviro_visor = bpy.props.BoolProperty(name='Retro: Disable in Combat/Scan Visor')\n" diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index 62e4d3542..b8cfd5ad0 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -126,8 +126,9 @@ bool MREA::Extract(const SpecBase& dataSpec, MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" - " bpy.context.scene.objects.unlink(ob)\n" - " bpy.data.objects.remove(ob)\n" + " if ob.type != 'CAMERA':\n" + " bpy.context.scene.objects.unlink(ob)\n" + " bpy.data.objects.remove(ob)\n" "bpy.types.Lamp.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Lamp.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" "\n";