Fix 36505: Collada exporter crashes Blender when exporting to locked file
This commit is contained in:
@@ -83,16 +83,6 @@ int collada_export(Scene *sce,
|
|||||||
{
|
{
|
||||||
ExportSettings export_settings;
|
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.filepath = (char *)filepath;
|
||||||
|
|
||||||
export_settings.apply_modifiers = apply_modifiers != 0;
|
export_settings.apply_modifiers = apply_modifiers != 0;
|
||||||
|
@@ -106,6 +106,24 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
|||||||
RNA_string_get(op->ptr, "filepath", filepath);
|
RNA_string_get(op->ptr, "filepath", filepath);
|
||||||
BLI_ensure_extension(filepath, sizeof(filepath), ".dae");
|
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 */
|
/* Options panel */
|
||||||
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||||
export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection");
|
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 */
|
/* get editmode results */
|
||||||
ED_object_editmode_load(CTX_data_edit_object(C));
|
ED_object_editmode_load(CTX_data_edit_object(C));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (collada_export(CTX_data_scene(C),
|
if (collada_export(CTX_data_scene(C),
|
||||||
filepath,
|
filepath,
|
||||||
apply_modifiers,
|
apply_modifiers,
|
||||||
|
Reference in New Issue
Block a user