From 07c370bdc960779fd840c82b12e10ddcfc56bc45 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Mon, 10 Oct 2022 12:31:45 +0200 Subject: [PATCH] Handle exception from export formats with unknown enum values Before, an export format with an invalid enum value (for example in the Encoding id) would crash Ardour with: unhandled exception (type std::exception) in signal handler: what: unknown enumerator FOO in PBD::EnumWriter That kind of error can happen if a new type is introduced and users switch back to versions without it. Instead, catch such exceptions while loading a format, log an error, and skip the format - similar to how other format loading errors are handled. --- libs/ardour/export_profile_manager.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/ardour/export_profile_manager.cc b/libs/ardour/export_profile_manager.cc index 44155a7aa8..60dc8eeccd 100644 --- a/libs/ardour/export_profile_manager.cc +++ b/libs/ardour/export_profile_manager.cc @@ -788,7 +788,13 @@ ExportProfileManager::load_format_from_disk (std::string const& path) return; } - ExportFormatSpecPtr format = handler->add_format (*root); + ExportFormatSpecPtr format; + try { + format = handler->add_format (*root); + } catch (PBD::unknown_enumeration& e) { + error << string_compose (_("Cannot export format read from %1: %2"), path, e.what()) << endmsg; + return; + } if (format->format_id () == ExportFormatBase::F_FFMPEG) { std::string unused;