From 159043803c1c174320ce88c2f8ed68e21dbf0a56 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Sun, 26 Jul 2026 04:30:06 -0700 Subject: [PATCH] imgui: fix crash when launching from UNC path (network shares) (#836) ## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change ImGui filebrowser extension crashes due to MinGW quirk about UNC path handling. ## Testing --- src/spice2x/external/imgui/imgui_filebrowser.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spice2x/external/imgui/imgui_filebrowser.h b/src/spice2x/external/imgui/imgui_filebrowser.h index 2f52538..94fcb1f 100644 --- a/src/spice2x/external/imgui/imgui_filebrowser.h +++ b/src/spice2x/external/imgui/imgui_filebrowser.h @@ -878,7 +878,15 @@ inline void ImGui::FileBrowser::UpdateFileRecords() inline void ImGui::FileBrowser::SetPwdUncatched(const std::filesystem::path &pwd) { - pwd_ = absolute(pwd); + // spice2x + // avoid MinGW std::filesystem::absolute() duplicating UNC server/share + // prefixes, which makes directory_iterator() throw during startup + // spice2x + const auto &nativePwd = pwd.native(); + const bool hasUncPrefix = nativePwd.size() >= 2 && + (nativePwd[0] == '\\' || nativePwd[0] == '/') && + (nativePwd[1] == '\\' || nativePwd[1] == '/'); + pwd_ = hasUncPrefix ? pwd : absolute(pwd); UpdateFileRecords(); selectedFilenames_.clear(); (*inputNameBuf_)[0] = '\0';