From 73c645820fe3df797b5e813c1881afabcab0fd7e Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 28 Mar 2023 14:33:39 +0200 Subject: [PATCH] TextEditor: use QScopeGuard instead of ExecuteOnDestruction Change-Id: I2d7c04d69ad49a121b157af2750eaed26bab9480 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index e61262094fc..4b0df472f89 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -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();