From: John Levon Date: Thu, 13 Mar 2003 17:50:39 +0000 (+0000) Subject: fix up the getChar() fixes X-Git-Tag: 1.6.10~17241 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c3fb8cffea726ebdd2f7ad89a2c825fa7dd750df;p=lyx.git fix up the getChar() fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6490 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 22cb627dd0..558a7201d8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-03-13 John Levon + + * paragraph_pimpl.C: fix Andre's backing out of the strong assertion + + * text.C: fix a getChar(pos) bug properly + 2003-03-13 Angus Leeming * commandtags.h: diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index d24e7180d7..c1ffec737f 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -252,19 +252,20 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end) Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const { + lyx::Assert(pos <= size()); + // This is stronger, and I belive that this is the assertion // that we should really use. (Lgb) + // Rationale - getChar() is really text[]. getInset(getChar(size())) + // makes no sense (crashes). The fact we return '\0' should be + // evidence enough - jbl //lyx::Assert(pos < size()); -#warning I believe pos() == size() is valid if the cursor is at the last position of the par. (Andre) - lyx::Assert(pos <= size()); - -#if 0 +#if 1 // This is in the critical path for loading! pos_type const siz = size(); - // Then this has no meaning. (Lgb) - if (!siz || pos == siz) { + if (pos == siz) { lyxerr << "getChar() on pos " << pos << " in par id " << owner_->id() << " of size " << siz << " is a bit silly !" << endl; diff --git a/src/text.C b/src/text.C index 9769d34b02..df6f0f9085 100644 --- a/src/text.C +++ b/src/text.C @@ -988,23 +988,25 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row) const int labeladdon = 0; int maxwidth = 0; - // Check if any insets are larger - for (pos_type pos = row->pos(); pos < pos_end; ++pos) { - if (row->par()->isInset(pos)) { - tmpfont = getFont(bview->buffer(), row->par(), pos); - tmpinset = row->par()->getInset(pos); - if (tmpinset) { + if (!row->par()->empty()) { + // Check if any insets are larger + for (pos_type pos = row->pos(); pos <= pos_end; ++pos) { + if (row->par()->isInset(pos)) { + tmpfont = getFont(bview->buffer(), row->par(), pos); + tmpinset = row->par()->getInset(pos); + if (tmpinset) { #if 1 // this is needed for deep update on initialitation - tmpinset->update(bview, tmpfont); + tmpinset->update(bview, tmpfont); #endif - asc = tmpinset->ascent(bview, tmpfont); - desc = tmpinset->descent(bview, tmpfont); - maxwidth += tmpinset->width(bview, tmpfont); - maxasc = max(maxasc, asc); - maxdesc = max(maxdesc, desc); + asc = tmpinset->ascent(bview, tmpfont); + desc = tmpinset->descent(bview, tmpfont); + maxwidth += tmpinset->width(bview, tmpfont); + maxasc = max(maxasc, asc); + maxdesc = max(maxdesc, desc); + } + } else { + maxwidth += singleWidth(bview, row->par(), pos); } - } else { - maxwidth += singleWidth(bview, row->par(), pos); } }