forked from qt-creator/qt-creator
TextEditor: Reuse qScopeGuard instead of ExecuteOnDestruction
Change-Id: I2ca7d4676bb4f34fbf59fd45bcd01d7857cb7e4e Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -4,10 +4,10 @@
|
|||||||
#include "basehoverhandler.h"
|
#include "basehoverhandler.h"
|
||||||
#include "texteditor.h"
|
#include "texteditor.h"
|
||||||
|
|
||||||
#include <utils/executeondestruction.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
|
#include <QScopeGuard>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -121,7 +121,7 @@ void BaseHoverHandler::process(TextEditorWidget *widget, int pos, ReportPriority
|
|||||||
|
|
||||||
void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, ReportPriority report)
|
void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, ReportPriority report)
|
||||||
{
|
{
|
||||||
Utils::ExecuteOnDestruction reportPriority([this, report](){ report(priority()); });
|
const auto cleanup = qScopeGuard([this, report] { report(priority()); });
|
||||||
|
|
||||||
QString tooltip = editorWidget->extraSelectionTooltip(pos);
|
QString tooltip = editorWidget->extraSelectionTooltip(pos);
|
||||||
if (!tooltip.isEmpty())
|
if (!tooltip.isEmpty())
|
||||||
|
|||||||
@@ -18,13 +18,13 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/executeondestruction.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QScopeGuard>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace TextEditor::Internal;
|
using namespace TextEditor::Internal;
|
||||||
@@ -158,7 +158,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
|||||||
bool isUpdate)
|
bool isUpdate)
|
||||||
{
|
{
|
||||||
// make sure to cleanup old proposals if we cannot find a new assistant
|
// make sure to cleanup old proposals if we cannot find a new assistant
|
||||||
Utils::ExecuteOnDestruction earlyReturnContextClear([this] { destroyContext(); });
|
auto cleanup = qScopeGuard([this] { destroyContext(); });
|
||||||
if (isWaitingForProposal())
|
if (isWaitingForProposal())
|
||||||
cancelCurrentRequest();
|
cancelCurrentRequest();
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
|||||||
QTC_ASSERT(assistInterface, return);
|
QTC_ASSERT(assistInterface, return);
|
||||||
|
|
||||||
// We got an assist provider and interface so no need to reset the current context anymore
|
// We got an assist provider and interface so no need to reset the current context anymore
|
||||||
earlyReturnContextClear.reset({});
|
cleanup.dismiss();
|
||||||
|
|
||||||
m_assistKind = kind;
|
m_assistKind = kind;
|
||||||
m_requestProvider = provider;
|
m_requestProvider = provider;
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
#include "texteditor.h"
|
#include "texteditor.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/executeondestruction.h>
|
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QPoint>
|
||||||
|
#include <QScopeGuard>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -333,10 +333,9 @@ static QColor colorFromFuncAndArgs(const QString &func, const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ColorPreviewHoverHandler::identifyMatch(TextEditorWidget *editorWidget,
|
void ColorPreviewHoverHandler::identifyMatch(TextEditorWidget *editorWidget,
|
||||||
int pos,
|
int pos, ReportPriority report)
|
||||||
ReportPriority report)
|
|
||||||
{
|
{
|
||||||
Utils::ExecuteOnDestruction reportPriority([this, report](){ report(priority()); });
|
const auto cleanup = qScopeGuard([this, report] { report(priority()); });
|
||||||
|
|
||||||
if (editorWidget->extraSelectionTooltip(pos).isEmpty()) {
|
if (editorWidget->extraSelectionTooltip(pos).isEmpty()) {
|
||||||
const QTextBlock tb = editorWidget->document()->findBlock(pos);
|
const QTextBlock tb = editorWidget->document()->findBlock(pos);
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/camelcasecursor.h>
|
#include <utils/camelcasecursor.h>
|
||||||
#include <utils/dropsupport.h>
|
#include <utils/dropsupport.h>
|
||||||
#include <utils/executeondestruction.h>
|
|
||||||
#include <utils/fadingindicator.h>
|
#include <utils/fadingindicator.h>
|
||||||
#include <utils/filesearch.h>
|
#include <utils/filesearch.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -91,9 +90,10 @@
|
|||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSequentialAnimationGroup>
|
#include <QScopeGuard>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QSequentialAnimationGroup>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
@@ -1435,7 +1435,7 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
doc = doc->clone(doc);
|
doc = doc->clone(doc);
|
||||||
Utils::ExecuteOnDestruction docDeleter([doc]() { delete doc; });
|
const auto cleanup = qScopeGuard([doc] { delete doc; });
|
||||||
|
|
||||||
QTextOption opt = doc->defaultTextOption();
|
QTextOption opt = doc->defaultTextOption();
|
||||||
opt.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
opt.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
|
||||||
@@ -5284,7 +5284,7 @@ void TextEditorWidgetPrivate::paintTextMarks(QPainter &painter, const ExtraAreaP
|
|||||||
int yoffset = blockBoundingRect.top();
|
int yoffset = blockBoundingRect.top();
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
Utils::ExecuteOnDestruction eod([&painter, size, yoffset, xoffset, overrideIcon]() {
|
const auto cleanup = qScopeGuard([&painter, size, yoffset, xoffset, overrideIcon] {
|
||||||
if (!overrideIcon.isNull()) {
|
if (!overrideIcon.isNull()) {
|
||||||
const QRect r(xoffset, yoffset, size, size);
|
const QRect r(xoffset, yoffset, size, size);
|
||||||
overrideIcon.paint(&painter, r, Qt::AlignCenter);
|
overrideIcon.paint(&painter, r, Qt::AlignCenter);
|
||||||
|
|||||||
Reference in New Issue
Block a user