]> git.lyx.org Git - lyx.git/commitdiff
Fix potential crashes related to element presence in a given map.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 8 Jul 2006 14:40:22 +0000 (14:40 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 8 Jul 2006 14:40:22 +0000 (14:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14377 a592a061-630c-0410-9148-cb99ea01b6c8

src/bufferview_funcs.C
src/rowpainter.C
src/text.C

index 354e248214a442ebaf7fa0b63d58f5869fe9fd4b..73644625f1ca01cec1795d7ec20d7667600f38fe 100644 (file)
@@ -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;
index 498d1c982f12a8fd6da67bd8aadf7f4460c036d0..681ff7ef13954ca4e6df36eccea9fc069c875e4c 100644 (file)
@@ -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);
index 94178761626a06c227ab07bbcfc6a834e48a64b5..da326879c5cc2c15f1fddf8e00f71e23b5337bc0 100644 (file)
@@ -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)