]> git.lyx.org Git - lyx.git/commitdiff
fix up the getChar() fixes
authorJohn Levon <levon@movementarian.org>
Thu, 13 Mar 2003 17:50:39 +0000 (17:50 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 13 Mar 2003 17:50:39 +0000 (17:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6490 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/paragraph_pimpl.C
src/text.C

index 22cb627dd054b16e284ce4ffbafe387c775b6f37..558a7201d86be12f3465a296f93f0f77b1b8509a 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-13  John Levon  <levon@movementarian.org>
+
+       * 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  <leeming@lyx.org>
 
        * commandtags.h:
index d24e7180d7d9a0d290fb79347a7eaa81ac376c10..c1ffec737fe9aa9cfdec229f5c1ed8fd44ed99db 100644 (file)
@@ -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;
index 9769d34b02b6e46edf0eac7733be4343015f3196..df6f0f90854f669ee6b468ad813d2f7e2faee30e 100644 (file)
@@ -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);
                }
        }