Do not give access to the actual data of the CoordCache. This prevents the use of the stored pointers which might be invalid.

See also r38011.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38012 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2011-03-23 17:43:13 +00:00
parent f4767138de
commit 4fcbb93e39
3 changed files with 5 additions and 10 deletions

View File

@ -52,8 +52,8 @@ void CoordCache::dump() const
{
LYXERR0("InsetCache contains:");
CoordCacheBase<Inset>::cache_type::const_iterator it =
getInsets().getData().begin();
for (; it != getInsets().getData().end(); ++it) {
getInsets().data_.begin();
for (; it != getInsets().data_.end(); ++it) {
// Warning: it is not guaranteed that inset is a valid pointer
// (therefore it has type 'void *') (see bug #7376).
void const * inset = it->first;

View File

@ -161,9 +161,6 @@ private:
typedef std::map<T const *, Geometry> cache_type;
cache_type data_;
public:
cache_type const & getData() const { return data_; }
};
/**

View File

@ -95,20 +95,18 @@ DocIterator bruteFind2(Cursor const & c, int x, int y)
int xo;
int yo;
Inset const * inset = &it.inset();
map<Inset const *, Geometry> const & data =
c.bv().coordCache().getInsets().getData();
map<Inset const *, Geometry>::const_iterator I = data.find(inset);
CoordCache const & cache = c.bv().coordCache();
// 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()) {
if (!cache.getInsets().has(inset)) {
it.top().pos() = 0;
return it;
}
Point o = I->second.pos;
Point const o = cache.getInsets().xy(inset);
inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;