diff options
-rw-r--r-- | src/plugins/texteditor/codeassist/codeassistant.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/syntaxhighlighter.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/textdocument.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 13 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index 317d5a132b7..1c499956187 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -254,7 +254,9 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason, case IAssistProvider::Asynchronous: { processor->setAsyncCompletionAvailableHandler([this, reason, processor](IAssistProposal *newProposal) { // do not delete this processor directly since this function is called from within the processor - QTimer::singleShot(0, [processor]() { delete processor; }); + QMetaObject::invokeMethod(QCoreApplication::instance(), [processor]() { + delete processor; + }, Qt::QueuedConnection); if (processor != m_asyncProcessor) return; invalidateCurrentRequestData(); diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index 5a35ce1b4f4..5688fe15f7c 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -34,7 +34,6 @@ #include <QTextDocument> #include <QPointer> -#include <qtimer.h> #include <cmath> @@ -310,7 +309,8 @@ void SyntaxHighlighter::setDocument(QTextDocument *doc) if (!d->noAutomaticHighlighting) { connect(d->doc, &QTextDocument::contentsChange, this, &SyntaxHighlighter::reformatBlocks); d->rehighlightPending = true; - QTimer::singleShot(0, this, &SyntaxHighlighter::delayedRehighlight); + QMetaObject::invokeMethod(this, &SyntaxHighlighter::delayedRehighlight, + Qt::QueuedConnection); } d->foldValidator.setup(qobject_cast<TextDocumentLayout *>(doc->documentLayout())); } diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index dfafcf2eb6e..e2699af59ee 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -51,7 +51,6 @@ #include <QScrollBar> #include <QStringList> #include <QTextCodec> -#include <QTimer> #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> @@ -1014,7 +1013,8 @@ void TextDocument::removeMarkFromMarksCache(TextMark *mark) auto scheduleLayoutUpdate = [documentLayout](){ // make sure all destructors that may directly or indirectly call this function are // completed before updating. - QTimer::singleShot(0, documentLayout, &QPlainTextDocumentLayout::requestUpdate); + QMetaObject::invokeMethod(documentLayout, &QPlainTextDocumentLayout::requestUpdate, + Qt::QueuedConnection); }; if (d->m_marksCache.isEmpty()) { diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 0235c77c37a..1dada6a2956 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -177,12 +177,12 @@ public: connect(m_editor, &QPlainTextEdit::cursorPositionChanged, this, &LineColumnLabel::update); connect(this, &FixedSizeClickLabel::clicked, ActionManager::instance(), [this] { emit m_editor->activateEditor(EditorManager::IgnoreNavigationHistory); - QTimer::singleShot(0, ActionManager::instance(), [] { + QMetaObject::invokeMethod(ActionManager::instance(), [] { if (Command *cmd = ActionManager::command(Core::Constants::GOTO)) { if (QAction *act = cmd->action()) act->trigger(); } - }); + }, Qt::QueuedConnection); }); } @@ -5421,7 +5421,7 @@ void TextEditorWidgetPrivate::updateHighlights() } if (m_highlightAutoComplete && !m_autoCompleteHighlightPos.isEmpty()) { - QTimer::singleShot(0, this, [this](){ + QMetaObject::invokeMethod(this, [this]() { const QTextCursor &cursor = q->textCursor(); auto popAutoCompletion = [&]() { return !m_autoCompleteHighlightPos.isEmpty() @@ -5432,7 +5432,7 @@ void TextEditorWidgetPrivate::updateHighlights() m_autoCompleteHighlightPos.pop_back(); updateAutoCompleteHighlight(); } - }); + }, Qt::QueuedConnection); } updateCurrentLineHighlight(); @@ -6287,7 +6287,7 @@ void TextEditorWidgetPrivate::requestUpdateLink(QMouseEvent *e) if (onText) { m_pendingLinkUpdate = cursor; - QTimer::singleShot(0, this, &TextEditorWidgetPrivate::updateLink); + QMetaObject::invokeMethod(this, &TextEditorWidgetPrivate::updateLink, Qt::QueuedConnection); return; } @@ -6444,7 +6444,8 @@ void TextEditorWidgetPrivate::scheduleUpdateHighlightScrollBar() return; m_scrollBarUpdateScheduled = true; - QTimer::singleShot(0, this, &TextEditorWidgetPrivate::updateHighlightScrollBarNow); + QMetaObject::invokeMethod(this, &TextEditorWidgetPrivate::updateHighlightScrollBarNow, + Qt::QueuedConnection); } Highlight::Priority textMarkPrioToScrollBarPrio(const TextMark::Priority &prio) |