diff --git a/src/opengl/main/generic_combo.hpp b/src/opengl/main/generic_combo.hpp index 65354565..496e19e8 100644 --- a/src/opengl/main/generic_combo.hpp +++ b/src/opengl/main/generic_combo.hpp @@ -1733,7 +1733,7 @@ class GenericCombo // want, outside or inside your objects if (std::ranges::empty(string)) { - return; + continue; } const char *c_str_value = std::ranges::data(string); { diff --git a/src/opengl/main/gui/gui.cpp b/src/opengl/main/gui/gui.cpp index 08cec8fb..8f119d90 100644 --- a/src/opengl/main/gui/gui.cpp +++ b/src/opengl/main/gui/gui.cpp @@ -1206,7 +1206,7 @@ void gui::hovered_tiles_panel() } void gui::combo_coo() { - bool remaster = m_field->is_remaster_from_fl_paths(); + bool remaster = m_field && m_field->is_remaster_from_fl_paths(); if (!remaster) { return; @@ -2447,7 +2447,7 @@ void gui::file_menu() { return; } - bool remaster = m_field->is_remaster_from_fl_paths(); + bool remaster = m_field && m_field->is_remaster_from_fl_paths(); if (remaster && ImGui::BeginMenu(gui_labels::language.data())) { const auto end_menu1 = glengine::ScopeGuard(&ImGui::EndMenu); @@ -4245,7 +4245,8 @@ gui::gui(GLFWwindow *const window) }); m_filter_window.register_is_remaster_callback( - [this]() -> bool { return m_field->is_remaster_from_fl_paths(); }); + [this]() -> bool + { return m_field && m_field->is_remaster_from_fl_paths(); }); if (m_field) { diff --git a/src/opengl/main/utilities.hpp b/src/opengl/main/utilities.hpp index 858516d7..0a82f762 100644 --- a/src/opengl/main/utilities.hpp +++ b/src/opengl/main/utilities.hpp @@ -56,12 +56,47 @@ concept erasable_range = std::ranges::range && requires(R &r) { } -> std::same_as; }; +inline std::filesystem::path + normalize_for_compare(const std::filesystem::path &p) +{ + auto norm = p.lexically_normal(); + +#if defined(_WIN32) + + // Windows: case-insensitive + auto s = norm.native(); + std::ranges::transform( + s, + s.begin(), + [](const auto ch) + { + return static_cast>( + std::tolower(ch)); + }); + return std::filesystem::path{ s }; +#else + // Linux / others: case-sensitive + return norm; +#endif +} + template constexpr inline bool sort_and_remove_duplicates(R &...ranges) noexcept { - bool changed = false; - const auto projection - = [](const auto &values) { return std::get<0>(values); }; + bool changed = false; + const auto projection = [](const auto &values) + { + using value_t = std::remove_cvref_t(values))>; + + if constexpr (std::is_same_v) + { + return normalize_for_compare(std::get<0>(values)); + } + else + { + return std::get<0>(values); + } + }; auto zip_view = std::ranges::views::zip(ranges...); if (!std::ranges::is_sorted(zip_view, {}, projection)) {