QTextEdit highlight line causing document corruption
===

I have a QTextEdit with this function

    void MyQTextEdit::highlightLine()
    {
        QTextCursor cursor = this->textCursor();
        cursor.setPosition(0, QTextCursor::MoveAnchor);
        cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, m_lineNumber);
        this->setTextCursor(cursor);
        QTextBlockFormat blockFormat = cursor.blockFormat();
        blockFormat.setBackground(QColor("yellow"));
        blockFormat.setNonBreakableLines(true);
        blockFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
        cursor.setBlockFormat(blockFormat);  <------------------------------------
    }

the line with the "<-----------------" appears to cause my document's text to be "corrupted" somehow, here's a screenshot: the image on the left is what happens WITH that line, the image on the right is what happens WITHOUT that line (commented away)

![enter image description here][1]


  [1]: http://i.stack.imgur.com/PF7y7.jpg

The highlighted line is at the top of the document so it's not visible.

Why is this happening? I set the following parameters to the QTextEdit

    setReadOnly(true);
    setAcceptRichText(false);
    setLineWrapMode(QTextEdit::NoWrap);

and as you can see I'm trying to load a plain C++ file, there's a syntax highlighter attached to the QTextEdit as described in the Qt documentation