From 7d192a2797489438528f888307b9f6ae340bfc72 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 27 Nov 2006 16:40:03 +0000 Subject: [PATCH] Fix crash in brutefind2() when the inset was not in the coordcache. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16079 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/cursor.C | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cursor.C b/src/cursor.C index 24befe6a99..3820ae29ff 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -49,6 +49,7 @@ #include #include +#include namespace lyx { @@ -96,7 +97,20 @@ namespace { int xo; int yo; InsetBase const * inset = &it.inset(); - Point o = c.bv().coordCache().getInsets().xy(inset); + std::map const & data = + c.bv().coordCache().getInsets().getData(); + std::map::const_iterator I = data.find(inset); + + // FIXME: in the case where the inset is not in the cache, this + // means that no part of it is visible on screen. In this case + // we don't do elaborate search and we just return the forwarded + // DocIterator at its beginning. + if (I == data.end()) { + it.top().pos() = 0; + return it; + } + + Point o = I->second; inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo); // Convert to absolute xo += o.x_; -- 2.39.2