So, in case anyone else wants to get in on this weird bug.

The bug report contains some instructions about how to reproduce. Basically, take a longish document and put the cursor at the end of a word somewhere in the middle. Then scroll up or down for a while and click the mouse in the text. If you're lucky, the view will jump to some seemingly random location. You may also see a ghost cursor before the click.

Here's what we know. The commit that caused the problem is r31757, here:

bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
        Font const & font) const
{
    if (!lyxrc.rtl_support)
        return false;

    // no RTL boundary at paragraph start
    if (pos == 0)
        return false;

    ParagraphMetrics & pm = par_metrics_[pit]; << this one
    // no RTL boundary in empty paragraph
    if (pm.rows().empty())
        return false;

The marked line is what causes the problem. If you put "return false" right after it, you still get the bug. If you put it before it, you don't. This means that a workaround, for some of us, is to disable RTL support.

If I put this before the access:

    if (!contains(pit))
        LYXERR0("Empty pit " << pit << " in " << text_);
    else
        LYXERR0("Have " << pit << " in " << text_);

then as I scroll I see this:

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(344): Empty pit 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(344): Empty pit 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00

TextMetrics.cpp(346): Have 58 in 0x177ab00


Note that par 58 is where the cursor is.


That the pit is "empty" just means that no par metrics yet exists for it in the metrics cache. So when we hit the offending line

ParagraphMetrics & pm = par_metrics_[pit];
it constructs a default ParagraphMetrics which, crucially, hasn't got its position() set. As a result, when we show the cursor, and in particular when we get to BufferView::cursorPosAndHeight, the calculated position ends up going like this:
BufferView.cpp(2297): Pre x: 318, y: 93

BufferView.cpp(2299): Post x: 318, y: -2029083275
BufferView.cpp(2325): x: 318, y: -2029083294, h: 24

I'm guessing that this is the cause of the problem.


Where ought the position to have been set?


Richard

Reply via email to