From 165f759e184b28be8bb071e6ed3308436e404238 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 11 Sep 2014 15:41:05 +0200 Subject: 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 --- src/libs/utils/uncommentselection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/uncommentselection.cpp b/src/libs/utils/uncommentselection.cpp index 21a4756c50..319ebea1c2 100644 --- a/src/libs/utils/uncommentselection.cpp +++ b/src/libs/utils/uncommentselection.cpp @@ -223,6 +223,8 @@ void Utils::unCommentSelection(QPlainTextEdit *edit, const CommentDefinition &de } } + cursor.endEditBlock(); + // adjust selection when commenting out if (hasSelection && !doMultiLineStyleUncomment && !doSingleLineStyleUncomment) { cursor = edit->textCursor(); @@ -238,6 +240,4 @@ void Utils::unCommentSelection(QPlainTextEdit *edit, const CommentDefinition &de } edit->setTextCursor(cursor); } - - cursor.endEditBlock(); } -- cgit v1.2.1