CVS commit by asj: 2 more fixes backported from head M +21 -7 kstextview.cpp 1.69.2.3 M +1 -1 kstextview.h 1.41.2.2 --- kdenetwork/ksirc/kstextview.cpp #1.69.2.2:1.69.2.3 @@ -994,17 +994,24 @@ void TextLine::appendItem( Item *i, int } -void TextLine::resetLayout( QPtrList &remainingItems ) +Item *TextLine::resetLayout( QPtrList &remainingItems, Item *last ) { + Item *lastLineItem = m_items.getLast(); Item *it = m_items.first(); + // We have to use the tobeDel structure or we call resetLayout on the Item + // twice for each item we want to delete + QPtrList tobeDel; while ( it ) { - if ( it->resetLayout( remainingItems.getLast() ) == Item::KeepItem ) - { + if ( it->resetLayout( last ) == Item::KeepItem ) + remainingItems.append( m_items.take() ); - it = m_items.current(); - } else - it = m_items.next(); + tobeDel.append( m_items.take() ); + + it = m_items.current(); } + m_items = tobeDel; + return lastLineItem; + } @@ -1096,6 +1103,7 @@ void TextParag::layout( int width ) TextLine *row = m_lines.first(); + Item *priorRowLast = 0x0; for (; row; row = m_lines.next() ) - row->resetLayout( items ); + priorRowLast = row->resetLayout( items, priorRowLast ); m_lines.clear(); @@ -1493,5 +1501,11 @@ bool TextView::removeParag( const TextPa clearSelection( false ); + int height = paragPtr->height(); m_parags.removeRef( paragPtr ); + + if(m_selectionStart.item != 0) + m_selectionStart.pos.ry() -= height; + if(m_selectionEnd.item != 0) + m_selectionEnd.pos.ry() -= height; layout( true ); --- kdenetwork/ksirc/kstextview.h #1.41.2.1:1.41.2.2 @@ -307,5 +307,5 @@ public: bool isEmpty() const { return m_items.isEmpty(); } - void resetLayout( QPtrList &remainingItems ); + Item *resetLayout( QPtrList &remainingItems, Item *last ); void paint( QPainter *p, int y );