From 3515824f65bb546f18cc03ecc7221c57a282ad54 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 19 Jan 2025 18:55:45 +0100 Subject: [PATCH] fix open strategy --- src/odr/internal/open_strategy.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/odr/internal/open_strategy.cpp b/src/odr/internal/open_strategy.cpp index c1134a7d..205c63a7 100644 --- a/src/odr/internal/open_strategy.cpp +++ b/src/odr/internal/open_strategy.cpp @@ -408,10 +408,12 @@ open_strategy::open_file(std::shared_ptr file, detected_types.end()); auto probe_types_end = std::unique(probe_types.begin(), probe_types.end()); probe_types.erase(probe_types_end, probe_types.end()); + // more specific file types are further down the list so we bring them up + std::ranges::reverse(probe_types); } - std::ranges::sort(probe_types, - priority_comparator(preference.file_type_priority)); + std::ranges::stable_sort(probe_types, + priority_comparator(preference.file_type_priority)); for (FileType as : probe_types) { std::vector probe_engines; @@ -426,8 +428,8 @@ open_strategy::open_file(std::shared_ptr file, probe_engines.erase(probe_engines_end, probe_engines.end()); } - std::ranges::sort(probe_engines, - priority_comparator(preference.engine_priority)); + std::ranges::stable_sort(probe_engines, + priority_comparator(preference.engine_priority)); for (DecoderEngine with : probe_engines) { auto decoded_file = open_file(file, as, with);