From 54e93460a53629c9428d3ed129a32f052b6bdd7e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 13 Feb 2015 15:06:16 +0100 Subject: (related: tdf#80715) sw: fix Ring::MoveTo() not doing anything... ... if the parameter is currently in the same list. The "boost::intrusive::circular_list_algorithms::transfer" has a precondition that the 2 parameters must not be in the same list. This causes an infinite loop in SwFindParaText::Find(), which is hiding the infinite loop that i'm trying to debug... While at it, remove some unnecessary complexity. Change-Id: Ib41f52c6d5c44ecc358c6170ee1e6e98729e1302 --- sw/inc/ring.hxx | 10 +++------- sw/qa/core/uwriter.cxx | 9 +++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index e0bfc5a30b90..9f70061e9725 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -135,16 +135,12 @@ namespace sw inline void Ring::MoveTo(value_type* pDestRing) { value_type* pThis = static_cast< value_type* >(this); + algo::unlink(pThis); // insert into "new" - if( pDestRing ) + if (pDestRing) { - if(algo::unique(pThis)) - algo::link_before(pDestRing, pThis); - else - algo::transfer(pDestRing, pThis); + algo::link_before(pDestRing, pThis); } - else - algo::unlink(pThis); } /** diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 96d2a34089ed..0c0635588e0c 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1372,6 +1372,15 @@ void SwDocTest::testIntrusiveRing() const TestRing* pRing = &r; CPPUNIT_ASSERT(pRing); } + TestRing foo, bar; + foo.MoveTo(&bar); + CPPUNIT_ASSERT_EQUAL(&foo, bar.GetNext()); + CPPUNIT_ASSERT_EQUAL(&foo, bar.GetPrev()); + CPPUNIT_ASSERT_EQUAL(&bar, foo.GetNext()); + CPPUNIT_ASSERT_EQUAL(&bar, foo.GetPrev()); + foo.MoveTo(&foo); + CPPUNIT_ASSERT_EQUAL(&bar, bar.GetNext()); + CPPUNIT_ASSERT_EQUAL(&bar, bar.GetPrev()); } void SwDocTest::setUp() -- cgit