From 86039563de87149a01ffb980b5ec99074b98fd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Sat, 14 May 2022 16:52:09 +0200 Subject: [PATCH] std::stable_sort() where libc++ debug mode breaks a unittest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Libc++ debug has a feature that randomizes equal elements during sort, which normally wouldn't make a difference, but some tests rely on specific order of tested data. The ones failing without this include: CppunitTest_sw_ooxmlexport testMsoPosition CppunitTest_sw_xhtmlexport testTdf66305 CppunitTest_sw_ww8export testCommentExport Change-Id: Id49846939a264150cc82091718ffe6b904d7130e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134337 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- svl/source/items/stylepool.cxx | 2 +- sw/source/filter/ww8/writerhelper.cxx | 2 +- sw/source/filter/ww8/wrtw8nds.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx index b74d0cb94729..dc992a6ede72 100644 --- a/svl/source/items/stylepool.cxx +++ b/svl/source/items/stylepool.cxx @@ -261,7 +261,7 @@ namespace { // Sort the parents using their name, if they have one. if (!rParentNames.empty()) { - std::sort(maParents.begin(), maParents.end(), + std::stable_sort(maParents.begin(), maParents.end(), [&rParentNames](const SfxItemSet* pA, const SfxItemSet* pB) { OUString aA; OUString aB; diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 6c62af767ab0..9c3bae38f14d 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -838,7 +838,7 @@ namespace sw RedlineStack::~RedlineStack() { - std::sort(maStack.begin(), maStack.end(), CompareRedlines()); + std::stable_sort(maStack.begin(), maStack.end(), CompareRedlines()); std::for_each(maStack.begin(), maStack.end(), SetInDocAndDelete(mrDoc)); } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 3ff1326c24a7..da9c73099dae 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -220,7 +220,7 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const SwTextNode& rTextNd) : Get list of any graphics which may be anchored from this paragraph. */ maFlyFrames = GetFramesInNode(rWr.m_aFrames, m_rNode); - std::sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys()); + std::stable_sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys()); /* #i18480#