diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 1eb5ac6ca4d..85bbaf4748f 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -83,16 +83,6 @@ int collada_export(Scene *sce, { ExportSettings export_settings; - /* annoying, collada crashes if file cant be created! [#27162] */ - if (!BLI_exists(filepath)) { - BLI_make_existing_file(filepath); /* makes the dir if its not there */ - if (!BLI_file_touch(filepath)) { - fprintf(stdout, "Collada export: Can not create: %s\n", filepath); - return 0; - } - } - /* end! */ - export_settings.filepath = (char *)filepath; export_settings.apply_modifiers = apply_modifiers != 0; diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index a1bb7a8ae88..70fa97bebc1 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -106,6 +106,24 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filepath); BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); + + /* Avoid File write exceptions in Collada */ + if (!BLI_exists(filepath)) { + BLI_make_existing_file(filepath); + if (!BLI_file_touch(filepath)) { + BKE_report(op->reports, RPT_ERROR, "Can't create export file"); + fprintf(stdout, "Collada export: Can not create: %s\n", filepath); + return OPERATOR_CANCELLED; + } + } + else if (!BLI_file_is_writable(filepath)) { + BKE_report(op->reports, RPT_ERROR, "Can't overwrite export file"); + fprintf(stdout, "Collada export: Can not modify: %s\n", filepath); + return OPERATOR_CANCELLED; + } + + /* Now the exporter can create and write the export file */ + /* Options panel */ apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); @@ -129,6 +147,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* get editmode results */ ED_object_editmode_load(CTX_data_edit_object(C)); + + if (collada_export(CTX_data_scene(C), filepath, apply_modifiers,