mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
* Clear the paragraph metrics cache as well on redraw:
On fullscreen redraw the metrics of all visible paragraphs are recreated and stored in the TextMetrics object. If the number of paragraphs on screen does not change everything is fine because the paragraph metrics cache is just updated. But if the number decreases it can happen that old paragraph metrics remain in the cache. If this happened because e.g. a paragraph was deleted, it's possible that the cached paragraph is longer than the one which is actually at the position now. Using the Row objects from the cached paragraphs then can trigger accesses to positions which would have been valid in the old paragraph, but go over the end of the paragraph which is there now. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18841 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5286634d17
commit
557521034f
@ -1440,6 +1440,15 @@ void BufferView::updateMetrics(bool singlepar)
|
||||
offset_ref_ = 0;
|
||||
}
|
||||
|
||||
if (!singlepar) {
|
||||
// Clear out the position cache in case of full screen redraw,
|
||||
coord_cache_.clear();
|
||||
|
||||
// Clear out paragraph metrics to avoid having invalid metrics
|
||||
// in the cache from paragraphs not relayouted below
|
||||
tm.clear();
|
||||
}
|
||||
|
||||
// If the paragraph metrics has changed, we can not
|
||||
// use the singlepar optimisation.
|
||||
if (singlepar
|
||||
@ -1459,10 +1468,6 @@ void BufferView::updateMetrics(bool singlepar)
|
||||
if (!singlepar)
|
||||
tm.redoParagraph(pit);
|
||||
|
||||
// Clear out the position cache in case of full screen redraw.
|
||||
if (!singlepar)
|
||||
coord_cache_.clear();
|
||||
|
||||
int y0 = tm.parMetrics(pit).ascent() - offset_ref_;
|
||||
|
||||
// Redo paragraphs above anchor if necessary.
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
/// \retval true if a full screen redraw is needed.
|
||||
/// \retval false if a single paragraph redraw is enough.
|
||||
bool redoParagraph(pit_type const pit);
|
||||
/// Clear cache of paragraph metrics
|
||||
void clear() { par_metrics_.clear(); }
|
||||
|
||||
///
|
||||
int ascent() const { return dim_.asc; }
|
||||
|
Loading…
Reference in New Issue
Block a user