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

This commit is contained in:
Gaia Clary 2014-09-30 12:21:53 +01:00 committed by Gaia Clary
parent 4268f1c8f2
commit c0276251d2
Notes: blender-bot 2023-12-22 20:14:11 +01:00
Referenced by issue #42022, Export dae crashes with un-applied modifiers using sl+open sim static export setting
2 changed files with 41 additions and 26 deletions

View File

@ -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);
int export_count = BLI_linklist_length(export_settings.export_set);
if (export_settings.sort_by_name)
bc_bubble_sort_by_Object_name(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 */

View File

@ -148,33 +148,36 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
ED_object_editmode_load(CTX_data_edit_object(C));
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,
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,
active_uv_only,
include_uv_textures,
include_material_textures,
use_texture_copies,
triangulate,
use_object_instantiation,
sort_by_name,
export_transformation_type,
open_sim);
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");
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;
}
}