Kaydet (Commit) 54e93460 authored tarafından Michael Stahl's avatar Michael Stahl

(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
üst b6e43aac
......@@ -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);
}
/**
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment