diff options
author | David Schulz <david.schulz@qt.io> | 2024-03-06 14:12:30 +0000 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2024-03-06 21:04:56 +0000 |
commit | 0539e2a0f63c25d24c78c4e12f8554714a7b1855 (patch) | |
tree | 98faeabd64579682eb44fc6681f209e245bf43bf /src/plugins/texteditor | |
parent | cc30e923ff761f2c94186cfd5eceee2074f4e69d (diff) |
Revert "TextEditor: Use synchronous highlighter by default"
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 <robert.loehning@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/textdocument.cpp | 16 | ||||
-rw-r--r-- | 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 2636ad46e2..cb421f2bf7 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<SyntaxHighlighter *()> &creator, bool threaded) { - delete d->m_highlighterRunner; + if (d->m_highlighterRunner) + delete d->m_highlighterRunner; - static const std::optional<bool> envValue = []() -> std::optional<bool> { - 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 5879d9e9ec..ad3fe262e2 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<SyntaxHighlighter *()>; - 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); |