From c1b155fbe87ce9bacab931edfcaaf21a447b6430 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Tue, 21 Aug 2007 10:54:04 +0000 Subject: [PATCH] simplify setInsetFont, removing a potential bug (an invalid DocIterator was built). Use CursorSlices when possible. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19690 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text2.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Text2.cpp b/src/Text2.cpp index 04f23499a5..dcabce00ed 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -314,25 +314,16 @@ void Text::setInsetFont(Buffer const & buffer, pit_type pit, pars_[pit].getInset(pos)->noFontChange()); Inset * const inset = pars_[pit].getInset(pos); - DocIterator dit = doc_iterator_begin(*inset); - // start of the last cell - DocIterator end = dit; - end.idx() = end.lastidx(); - - while (true) { - Text * text = dit.text(); - Inset * cell = dit.realInset(); - if (text && cell) { - DocIterator cellbegin = doc_iterator_begin(*cell); + CursorSlice::idx_type endidx = inset->nargs(); + for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) { + Text * text = cs.text(); + if (text) { // last position of the cell - DocIterator cellend = cellbegin; + CursorSlice cellend = cs; cellend.pit() = cellend.lastpit(); cellend.pos() = cellend.lastpos(); - text->setFont(buffer, cellbegin.top(), cellend.top(), font, toggleall); + text->setFont(buffer, cs, cellend, font, toggleall); } - if (dit == end) - break; - dit.forwardIdx(); } } -- 2.39.2