impr: Handle and show NFD errors (#995)

This PR handles errors that NFD might encounter (both in Init() and the
other method to open the dialog), and log them in the logs and in the
GUI

This (among other) fix the crash I had running ImHex as root and opening
a file
This commit is contained in:
Thomas
2023-03-26 11:02:51 +02:00
committed by GitHub
parent 725e32250b
commit fabb1596e5
5 changed files with 20 additions and 11 deletions

View File

@@ -123,11 +123,11 @@ namespace hex::plugin::builtin {
ImHexApi::HexEditor::impl::setCurrentSelection(region);
});
fs::setFileBrowserErrorCallback([]{
fs::setFileBrowserErrorCallback([](const std::string& errMsg){
#if defined(NFD_PORTAL)
View::showErrorPopup("hex.builtin.popup.error.file_dialog.portal"_lang);
View::showErrorPopup(hex::format("hex.builtin.popup.error.file_dialog.portal"_lang, errMsg));
#else
View::showErrorPopup("hex.builtin.popup.error.file_dialog.common"_lang);
View::showErrorPopup(hex::format("hex.builtin.popup.error.file_dialog.common"_lang, errMsg));
#endif
});