diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-04 16:37:49 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-04 16:37:49 +0300 |
commit | 0e87a35f8e4571688e402623f8da23840e02f96b (patch) | |
tree | 3cd6a9c43aa5afeb97062e8d28fee803bfb67be8 /source/blender/io | |
parent | f5919a7ad192eae65ad48634d91288bf6cc80468 (diff) | |
parent | e8483f9bd721f93ec8c21fb339a518096042537d (diff) |
Merge remote-tracking branch 'origin/blender-v2.90-release'
Diffstat (limited to 'source/blender/io')
-rw-r--r-- | source/blender/io/alembic/exporter/abc_export_capi.cc | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index 98c551c635c..8c5f3d89870 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -48,6 +48,7 @@ static CLG_LogRef LOG = {"io.alembic"}; #include <algorithm> +#include <memory> struct ExportJobData { Main *bmain; @@ -103,17 +104,41 @@ static void export_startjob(void *customdata, const bool export_animation = (data->params.frame_start != data->params.frame_end); // Create the Alembic archive. - ABCArchive abc_archive(data->bmain, scene, data->params, std::string(data->filename)); + std::unique_ptr<ABCArchive> abc_archive; + try { + abc_archive = std::make_unique<ABCArchive>( + data->bmain, scene, data->params, std::string(data->filename)); + } + catch (const std::exception &ex) { + std::stringstream error_message_stream; + error_message_stream << "Error writing to " << data->filename; + const std::string &error_message = error_message_stream.str(); + + // The exception message can be very cryptic (just "iostream error" on Linux, for example), so + // better not to include it in the report. + CLOG_ERROR(&LOG, "%s: %s", error_message.c_str(), ex.what()); + WM_report(RPT_ERROR, error_message.c_str()); + data->export_ok = false; + return; + } + catch (...) { + // Unknown exception class, so we cannot include its message. + std::stringstream error_message_stream; + error_message_stream << "Unknown error writing to " << data->filename; + WM_report(RPT_ERROR, error_message_stream.str().c_str()); + data->export_ok = false; + return; + } - ABCHierarchyIterator iter(data->depsgraph, &abc_archive, data->params); + ABCHierarchyIterator iter(data->depsgraph, abc_archive.get(), data->params); if (export_animation) { CLOG_INFO(&LOG, 2, "Exporting animation"); // Writing the animated frames is not 100% of the work, but it's our best guess. - const float progress_per_frame = 1.0f / std::max(size_t(1), abc_archive.total_frame_count()); - ABCArchive::Frames::const_iterator frame_it = abc_archive.frames_begin(); - const ABCArchive::Frames::const_iterator frames_end = abc_archive.frames_end(); + const float progress_per_frame = 1.0f / std::max(size_t(1), abc_archive->total_frame_count()); + ABCArchive::Frames::const_iterator frame_it = abc_archive->frames_begin(); + const ABCArchive::Frames::const_iterator frames_end = abc_archive->frames_end(); for (; frame_it != frames_end; frame_it++) { double frame = *frame_it; @@ -128,7 +153,7 @@ static void export_startjob(void *customdata, BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain); CLOG_INFO(&LOG, 2, "Exporting frame %.2f", frame); - ExportSubset export_subset = abc_archive.export_subset_for_frame(frame); + ExportSubset export_subset = abc_archive->export_subset_for_frame(frame); iter.set_export_subset(export_subset); iter.iterate_and_write(); |