]> git.lyx.org Git - features.git/commit
Fix bug #7490.
authorRichard Heck <rgheck@comcast.net>
Tue, 26 Apr 2011 22:41:48 +0000 (22:41 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 26 Apr 2011 22:41:48 +0000 (22:41 +0000)
commit2bf904ca346e9b2bf9b2bbc36e0beea8f033dbb1
tree1f652624d71d2a9e26105695f4ae61bead3cd0a7
parent637d43a32b7bb73f9f95c1e0a058e03cf029cbb8
Fix bug #7490.

As the bug report notes, you do NOT get this crash if you move up or
down in the table a bit before you do the rest. The reason is that
moving up and down sets the cursor's x_target_, and it is because that
is not set that we enter the other code at all and eventually crash.
That is, in InsetTabular's dispatch, we have:

(*) cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, cur.targetX());

You can see the potential for trouble here already. cur.pit() is in the
NEW cell, i.e., the one to which we are moving; it was changed a few
lines previously, and cur.idx() points to the new cell, too. But we are
trying to calculate cur.pos(), which means that cur.pos() is currently
the one from the OLD cell. So the cursor is in an inconsistent state.
Calling cur.targetX() leads us to call Cursor::getPos(), and that is
what causes the crash.

We fix the problem by making sure we call targetX() on the original
cursor. The same problem clearly exists in the DOWN stuff, so we fix
that, too.

By the way, should we be setting x_target_ here once we have calculated
it?

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38530 a592a061-630c-0410-9148-cb99ea01b6c8
src/insets/InsetTabular.cpp