Commit: 19d4d059f1816111b2d7bb89a2b2665c097d8959
Author: gaiaclary
Date:   Tue Sep 30 12:21:53 2014 +0100
Branches: blender-v2.72-release
https://developer.blender.org/rB19d4d059f1816111b2d7bb89a2b2665c097d8959

fix T42022 Attempt to export empty set of objects resulted in an exception

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

M       source/blender/collada/collada.cpp
M       source/blender/editors/io/io_collada.c

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

diff --git a/source/blender/collada/collada.cpp 
b/source/blender/collada/collada.cpp
index 223ab3e..ffbbb86 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -111,16 +111,28 @@ int collada_export(Scene *sce,
 
        eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : 
OB_SET_ALL;
        export_settings.export_set = BKE_object_relational_superset(sce, 
objectSet, (eObRelationTypes)includeFilter);
-
-       if (export_settings.sort_by_name)
-               bc_bubble_sort_by_Object_name(export_settings.export_set);
+       int export_count = BLI_linklist_length(export_settings.export_set);
+
+       if (export_count==0)
+       {
+               if (export_settings.selected) {
+                       fprintf(stderr, "Collada: Found no objects to 
export.\nPlease ensure that all objects which shall be exported are also 
visible in the 3D Viewport.\n");
+               }
+               else{
+                       fprintf(stderr, "Collada: Your scene seems to be empty. 
No Objects will be exported.\n");
+               }
+       }
+       else {
+               if (export_settings.sort_by_name)
+                       
bc_bubble_sort_by_Object_name(export_settings.export_set);
+       }
 
        DocumentExporter exporter(&export_settings);
        exporter.exportCurrentScene(sce);
 
        BLI_linklist_free(export_settings.export_set, NULL);
 
-       return 1;
+       return export_count;
 }
 
 /* end extern C */
diff --git a/source/blender/editors/io/io_collada.c 
b/source/blender/editors/io/io_collada.c
index a413054..bc23c2d 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -148,33 +148,36 @@ static int wm_collada_export_exec(bContext *C, wmOperator 
*op)
        ED_object_editmode_load(CTX_data_edit_object(C));
 
 
-
-       if (collada_export(CTX_data_scene(C),
-                          filepath,
-                          apply_modifiers,
-                          export_mesh_type,
-                          selected,
-                          include_children,
-                          include_armatures,
-                          include_shapekeys,
-                          deform_bones_only,
-
-                          active_uv_only,
-                          include_uv_textures,
-                          include_material_textures,
-                          use_texture_copies,
-
-                          triangulate,
-                          use_object_instantiation,
-                          sort_by_name,
-                          export_transformation_type,
-                          open_sim))
-       {
-               return OPERATOR_FINISHED;
-       }
-       else {
-               BKE_report(op->reports, RPT_WARNING, "Export file not created");
+       int export_count = collada_export(CTX_data_scene(C),
+               filepath,
+               apply_modifiers,
+               export_mesh_type,
+               selected,
+               include_children,
+               include_armatures,
+               include_shapekeys,
+               deform_bones_only,
+
+               active_uv_only,
+               include_uv_textures,
+               include_material_textures,
+               use_texture_copies,
+
+               triangulate,
+               use_object_instantiation,
+               sort_by_name,
+               export_transformation_type,
+               open_sim);
+
+       if(export_count == 0) {
+               BKE_report(op->reports, RPT_WARNING, "Export file is empty");
                return OPERATOR_CANCELLED;
+               }
+       else {
+               char buff[100];
+               sprintf(buff, "Exported %d Objects", export_count);
+               BKE_report(op->reports, RPT_INFO, buff);
+               return OPERATOR_FINISHED;
        }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to