diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-08-24 13:51:05 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-08-24 13:51:05 +0400 |
commit | 3741a588bca93c00b786df7d496c813ae061c2f1 (patch) | |
tree | b7e1abadede280d3f72bfc234f7ad20c6c1d3ad1 /source/blender/editors/io | |
parent | bffd7767e247a5077acec5446b46bd2336dd86d0 (diff) |
Fix 36505: Collada exporter crashes Blender when exporting to locked file
Diffstat (limited to 'source/blender/editors/io')
-rw-r--r-- | source/blender/editors/io/io_collada.c | 20 |
1 files changed, 20 insertions, 0 deletions
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, |