(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
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index e0bfc5a..9f70061 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -135,16 +135,12 @@ namespace sw
inline void Ring<value_type>::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 96d2a34..0c06355 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()