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
This commit is contained in:
Abdelrazak Younes 2006-07-08 14:40:22 +00:00
parent 82a4214f7b
commit 7cca51ed18
3 changed files with 13 additions and 3 deletions

View File

@ -201,8 +201,12 @@ Point coordOffset(DocIterator const & dit, bool boundary)
Point getPos(DocIterator const & dit, bool boundary) Point getPos(DocIterator const & dit, bool boundary)
{ {
CursorSlice const & bot = dit.bottom(); CursorSlice const & bot = dit.bottom();
CoordCache::InnerParPosCache const & cache = CoordCache::ParPosCache::const_iterator cache_it =
theCoords.getParPos().find(bot.text())->second; 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()); CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit());
if (it == cache.end()) { if (it == cache.end()) {
//lyxerr << "cursor out of view" << std::endl; //lyxerr << "cursor out of view" << std::endl;

View File

@ -797,11 +797,14 @@ void paintPar
static PainterInfo nullpi(pi.base.bv, nop); static PainterInfo nullpi(pi.base.bv, nop);
int const ww = pi.base.bv->workHeight(); int const ww = pi.base.bv->workHeight();
theCoords.parPos()[&text][pit] = Point(x, y);
Paragraph const & par = text.paragraphs()[pit]; Paragraph const & par = text.paragraphs()[pit];
if (par.rows().empty())
return;
RowList::const_iterator const rb = par.rows().begin(); RowList::const_iterator const rb = par.rows().begin();
RowList::const_iterator const re = par.rows().end(); RowList::const_iterator const re = par.rows().end();
theCoords.parPos()[&text][pit] = Point(x, y);
y -= rb->ascent(); y -= rb->ascent();
lyx::size_type rowno(0); lyx::size_type rowno(0);

View File

@ -2245,6 +2245,9 @@ int LyXText::cursorY(CursorSlice const & sl, bool boundary) const
{ {
//lyxerr << "LyXText::cursorY: boundary: " << boundary << std::endl; //lyxerr << "LyXText::cursorY: boundary: " << boundary << std::endl;
Paragraph const & par = getPar(sl.pit()); Paragraph const & par = getPar(sl.pit());
if (par.rows().empty())
return 0;
int h = 0; int h = 0;
h -= pars_[0].rows()[0].ascent(); h -= pars_[0].rows()[0].ascent();
for (pit_type pit = 0; pit < sl.pit(); ++pit) for (pit_type pit = 0; pit < sl.pit(); ++pit)