fix: Crash when closing the file picker without picking a file
This commit is contained in:
parent
e34f94bb79
commit
461c5eac3e
@ -71,7 +71,7 @@ namespace hex::fs {
|
||||
bool openFileBrowser(DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath) {
|
||||
NFD::Init();
|
||||
|
||||
nfdchar_t *outPath;
|
||||
nfdchar_t *outPath = nullptr;
|
||||
nfdresult_t result;
|
||||
switch (mode) {
|
||||
case DialogMode::Open:
|
||||
@ -87,6 +87,7 @@ namespace hex::fs {
|
||||
hex::unreachable();
|
||||
}
|
||||
|
||||
if (result == NFD_OKAY && outPath != nullptr) {
|
||||
std::fs::path path;
|
||||
#if defined(OS_LINUX)
|
||||
// xdg-desktop-portal, which is the file picker backend used on Linux, returns all paths with URI encoding.
|
||||
@ -97,7 +98,6 @@ namespace hex::fs {
|
||||
path = reinterpret_cast<char8_t*>(outPath);
|
||||
#endif
|
||||
|
||||
if (result == NFD_OKAY) {
|
||||
callback(path);
|
||||
NFD::FreePath(outPath);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user