From 0539e2a0f63c25d24c78c4e12f8554714a7b1855 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 6 Mar 2024 14:12:30 +0000 Subject: [PATCH] Revert "TextEditor: Use synchronous highlighter by default" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1c47a0a301c291b0ec450b7a141c5067d402dac4. Changing the default revealed a crash that seem to be caused by the async syntax highlighter infra structure changes. Revert the default for now to figure out the cause of the crash. Task-number: QTCREATORBUG-30494 Change-Id: I1d0388c29d206cb25f2d58e4b305aa8303db2a60 Reviewed-by: Robert Löhning Reviewed-by: Reviewed-by: Eike Ziller --- src/plugins/texteditor/textdocument.cpp | 16 ++++++---------- src/plugins/texteditor/textdocument.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index 2636ad46e23..cb421f2bf7c 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -914,23 +914,19 @@ bool TextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type void TextDocument::resetSyntaxHighlighter(const std::function &creator, bool threaded) { - delete d->m_highlighterRunner; + if (d->m_highlighterRunner) + delete d->m_highlighterRunner; - static const std::optional envValue = []() -> std::optional { - const QString key("QTC_USE_THREADED_HIGHLIGHTER"); - if (qtcEnvironmentVariableIsSet(key)) { - const QString value = qtcEnvironmentVariable(key).toUpper(); - return value != "FALSE" && value != "0"; - } - return {}; - }(); + static const bool envValue + = qtcEnvironmentVariable("QTC_USE_THREADED_HIGHLIGHTER", "TRUE").toUpper() + == QLatin1String("TRUE"); SyntaxHighlighter *highlighter = creator(); highlighter->setFontSettings(TextEditorSettings::fontSettings()); highlighter->setMimeType(mimeType()); d->m_highlighterRunner = new SyntaxHighlighterRunner(highlighter, document(), - envValue.value_or(threaded)); + threaded && envValue); } void TextDocument::cleanWhitespace(const QTextCursor &cursor) diff --git a/src/plugins/texteditor/textdocument.h b/src/plugins/texteditor/textdocument.h index 5879d9e9ec2..ad3fe262e24 100644 --- a/src/plugins/texteditor/textdocument.h +++ b/src/plugins/texteditor/textdocument.h @@ -127,7 +127,7 @@ public: QTextDocument *document() const; using SyntaxHighLighterCreator = std::function; - void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator, bool threaded = false); + void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator, bool threaded = true); SyntaxHighlighterRunner *syntaxHighlighterRunner() const; bool reload(QString *errorString, QTextCodec *codec);