Fix 36505: Collada exporter crashes Blender when exporting to locked file

This commit is contained in:
2013-08-24 09:51:05 +00:00
parent bffd7767e2
commit 3741a588bc
2 changed files with 20 additions and 10 deletions

View File

@@ -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;

View File

@@ -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,