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
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 6 additions and 3 deletions

View File

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