TextEditor: use QScopeGuard instead of ExecuteOnDestruction

Change-Id: I2d7c04d69ad49a121b157af2750eaed26bab9480
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-03-28 14:33:39 +02:00
parent 0f3f5fb4d8
commit 73c645820f

View File

@@ -2533,7 +2533,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
{
ICore::restartTrimmer();
ExecuteOnDestruction eod([&]() { d->clearBlockSelection(); });
auto clearBlockSelectionGuard = qScopeGuard([&]() { d->clearBlockSelection(); });
if (!isModifier(e) && mouseHidingEnabled())
viewport()->setCursor(Qt::BlankCursor);
@@ -2803,8 +2803,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
}
if (blockSelectionOperation != QTextCursor::NoMove) {
auto doNothing = [](){};
eod.reset(doNothing);
clearBlockSelectionGuard.dismiss();
d->handleMoveBlockSelection(blockSelectionOperation);
} else if (!d->cursorMoveKeyEvent(e)) {
QTextCursor cursor = textCursor();