Editors: sync the layout with the contents before setting text cursor

Not doing this makes the QPlainTextEdit interact with an invalid
layout, potentially causing crashes. Now the cursor setting itself is
not part of the undo stack anymore, but as undoing sets the cursor
itself, that shouldn't be a problem.

Change-Id: Ic6f8ee9781faed655ac20f058b562c098ced20ae
Task-number: QTCREATORBUG-12987
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Ulf Hermann
2014-09-11 15:41:05 +02:00
committed by hjk
parent 602746950b
commit 165f759e18

View File

@@ -223,6 +223,8 @@ void Utils::unCommentSelection(QPlainTextEdit *edit, const CommentDefinition &de
} }
} }
cursor.endEditBlock();
// adjust selection when commenting out // adjust selection when commenting out
if (hasSelection && !doMultiLineStyleUncomment && !doSingleLineStyleUncomment) { if (hasSelection && !doMultiLineStyleUncomment && !doSingleLineStyleUncomment) {
cursor = edit->textCursor(); cursor = edit->textCursor();
@@ -238,6 +240,4 @@ void Utils::unCommentSelection(QPlainTextEdit *edit, const CommentDefinition &de
} }
edit->setTextCursor(cursor); edit->setTextCursor(cursor);
} }
cursor.endEditBlock();
} }