Skip to content

Conversation

@ddddhm1234
Copy link

On Windows systems, when using file_dialog to browse a directory without access permission, such as C:\Users<your user>\SendTo, dpg would hang or crash. This PR fixes this bug.

Operating system:
Windows

Reproduce:
Use file_dialog to browse any directory without access permission on Windows

The origin of this bug:
In ImGuiFileDialog.cpp, ScanDir function

//const auto wpath = IGFD::Utils::WGetString(path.c_str());
const std::filesystem::path fspath(path);
const auto dir_iter = std::filesystem::directory_iterator(fspath); //  <--------  If the current user doesn't have permission to access this directory, an exception will be thrown here without a try block to handle it.

The bug manifests as a freeze or crash of DPG when attempting to access a directory that the current user does not have permission to access on windows using file_dialog. This commit fixes the issue by adding a code snippet that checks the permission to access the target directory before attempting to do so. If the user does not have permission, the program will not access the target directory and stay in the current path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant