From ac004eee7001301d8c274ad997b75f41268486d8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 22 May 2024 15:57:59 -0600 Subject: [PATCH] avoid all potential charset conversion when displaying an error relating to filename errors --- libs/pbd/file_utils.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index e65f032a84..4714bbc741 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -138,18 +139,14 @@ run_functor_for_paths (vector& result, } } catch (Glib::FileError const& err) { -#ifndef NDEBUG - warning << string_compose (_("Cannot access file: %1"), err.what()) << endmsg; -#endif + char errstr[PATH_MAX*2]; + snprintf (errstr, sizeof (errstr), "Cannot access file: %s", err.what().c_str()); + warning << errstr << endmsg; } catch (Glib::ConvertError const& err) { -#ifndef NDEBUG - warning << string_compose (_("Could not convert filename: %1"), err.what()) << endmsg; -#endif - } catch (...) { -#ifndef NDEBUG - warning << string_compose (_("Could not convert filename: '%1'"), *i) << endmsg; -#endif + char errstr[PATH_MAX*2]; + snprintf (errstr, sizeof (errstr), "Cannot convert filename: %s", err.what().c_str()); + warning << errstr << endmsg; } } }