Catch Glib::ConvertError when checking for files

This fixes some edge-cases when scanning recent sessions
in get_state_files_in_directory() and likely some other
places that use run_functor_for_paths in case the folder
contains files with non UTF-8 names.
This commit is contained in:
Robin Gareus 2023-04-03 22:10:11 +02:00
parent 2c4d1e011c
commit 473f575a05
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -31,6 +31,7 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <glibmm/convert.h>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
#include <glibmm/pattern.h> #include <glibmm/pattern.h>
@ -130,9 +131,11 @@ run_functor_for_paths (vector<string>& result,
} }
} }
} }
catch (Glib::FileError const& err) catch (Glib::FileError const& err) {
{ warning << string_compose (_("Cannot access file: %1"), err.what()) << endmsg;
warning << err.what() << endmsg; }
catch (Glib::ConvertError const& err) {
warning << string_compose (_("Could not convert filename: %1"), err.what()) << endmsg;
} }
} }
} }