From 7cca51ed183e9560fd658d06f4fe893dfacd85a1 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 8 Jul 2006 14:40:22 +0000 Subject: [PATCH 1/1] Fix potential crashes related to element presence in a given map. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14377 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/bufferview_funcs.C | 8 ++++++-- src/rowpainter.C | 5 ++++- src/text.C | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 354e248214..73644625f1 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -201,8 +201,12 @@ Point coordOffset(DocIterator const & dit, bool boundary) Point getPos(DocIterator const & dit, bool boundary) { CursorSlice const & bot = dit.bottom(); - CoordCache::InnerParPosCache const & cache = - theCoords.getParPos().find(bot.text())->second; + CoordCache::ParPosCache::const_iterator cache_it = + theCoords.getParPos().find(bot.text()); + if (cache_it == theCoords.getParPos().end()) + return Point(-1, -1); + + CoordCache::InnerParPosCache const & cache = cache_it->second; CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit()); if (it == cache.end()) { //lyxerr << "cursor out of view" << std::endl; diff --git a/src/rowpainter.C b/src/rowpainter.C index 498d1c982f..681ff7ef13 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -797,11 +797,14 @@ void paintPar static PainterInfo nullpi(pi.base.bv, nop); int const ww = pi.base.bv->workHeight(); + theCoords.parPos()[&text][pit] = Point(x, y); + Paragraph const & par = text.paragraphs()[pit]; + if (par.rows().empty()) + return; RowList::const_iterator const rb = par.rows().begin(); RowList::const_iterator const re = par.rows().end(); - theCoords.parPos()[&text][pit] = Point(x, y); y -= rb->ascent(); lyx::size_type rowno(0); diff --git a/src/text.C b/src/text.C index 9417876162..da326879c5 100644 --- a/src/text.C +++ b/src/text.C @@ -2245,6 +2245,9 @@ int LyXText::cursorY(CursorSlice const & sl, bool boundary) const { //lyxerr << "LyXText::cursorY: boundary: " << boundary << std::endl; Paragraph const & par = getPar(sl.pit()); + if (par.rows().empty()) + return 0; + int h = 0; h -= pars_[0].rows()[0].ascent(); for (pit_type pit = 0; pit < sl.pit(); ++pit) -- 2.39.2