commit 51cc1a1cbed395ab79ffa98765231efac4112c56
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Jan 30 11:18:04 2015 +0100
Do not modify the changed() status of rows when no drawing has taken place
There are several places in the code where a row is painted with drawing
disabled in the painter. The goal is only to recompute inset positions.
Such a case happens in BufferView::checkCursorScrollOffset, as part of the
horizontal scrolling patch. Note that this particular piece of code should
eventually be removed, since it is a performance problem.
It makes sense to consider that only a real painting of a row should change
its status. However, I would not be surprised if this change would break other
things.
Fixes: #9388
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index fd2042f..7cb99cd 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2970,6 +2970,19 @@ void BufferView::checkCursorScrollOffset(PainterInfo &
pi)
// Set the row on which the cursor lives.
setCurrentRowSlice(rowSlice);
+ /** FIXME: the code below adds an extraneous computation of inset
+ * positions, and can therefore be bad for performance (think for
+ * example about a very large tabular inset. Redawing the row
+ * where it is means redrawing the whole screen).
+ *
+ * The bug that this fixes is the following: assume that there is
+ * a very large math inset. Upon entering the inset, when pressing
+ * `End', the row is not scrolled and the cursor is not visible. I
+ * am not sure why the extra row computation fixes the problem,
+ * actually.
+ *
+ * A proper fix should be found and this code should be removed.
+ */
// Force the recomputation of inset positions
bool const drawing = pi.pain.isDrawingEnabled();
pi.pain.setDrawingEnabled(false);
@@ -2978,6 +2991,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
-d->horiz_scroll_offset_, 0);
rp.paintText();
pi.pain.setDrawingEnabled(drawing);
+ /** END of bad code */
// Current x position of the cursor in pixels
int const cur_x = getPos(d->cursor_).x_;
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index f29202c..2119f8e 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1878,7 +1878,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi,
pit_type const pit, int const
}
// Row signature; has row changed since last paint?
- row.setCrc(pm.computeRowSignature(row, bparams));
+ if (pi.pain.isDrawingEnabled())
+ row.setCrc(pm.computeRowSignature(row, bparams));
bool row_has_changed = row.changed()
|| rowSlice == bv_->lastRowSlice();
@@ -1916,7 +1917,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi,
pit_type const pit, int const
LYXERR(Debug::PAINTING, foreword << "pit=" << pit << "
row=" << i
<< " row_selection=" << row.selection()
<< " full_repaint=" << pi.full_repaint
- << " row_has_changed=" << row_has_changed);
+ << " row_has_changed=" << row_has_changed
+ << " drawingEnabled=" <<
pi.pain.isDrawingEnabled());
}
// Backup full_repaint status and force full repaint