From a9bc3e688b7769481d53839dfe0a082a58fc75ed Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 1 Jan 2007 09:31:43 +0000 Subject: [PATCH] Fix crash when scrolling up using the arrow keys. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16450 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/text2.C | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/text2.C b/src/text2.C index c41a9c4c1e..26c85f3b1c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -757,7 +757,12 @@ pos_type LyXText::getColumnNearX(BufferView const & bv, int right_margin, { Buffer const & buffer = *bv.buffer(); TextMetrics const & tm = bv.textMetrics(this); - int const xo = bv.coordCache().get(this, pit).x_; + + /// For the main LyXText, it is possible that this pit is not + /// yet in the CoordCache when moving cursor up. + /// x Paragraph coordinate is always 0 for main text anyway. + int const xo = isMainText(*bv.buffer())? + 0 : bv.coordCache().get(this, pit).x_; x -= xo; RowMetrics const r = tm.computeRowMetrics(pit, row); Paragraph const & par = pars_[pit]; -- 2.39.2