Commit Graph

23 Commits

Author SHA1 Message Date
David Schulz
2428db2a30 TextEditor: Fix crash in SyntaxHighlighter
The SyntaxHighlighterRunner is deleted by deleteLater in the
TextDocument destructor. This makes it possible that the
SyntaxHighlighter inside the runner lives longer than the document
itself. Avoid this by making the document the parent of the
SyntaxHighlighter like before the async highlighter patch series.

Fixes: QTCREATORBUG-30494
Change-Id: I6ce9c35ab400b17f2a1a6f3c3bd98df23f41c71e
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-03-07 08:20:07 +00:00
Artem Sokolovskii
bb87db09e2 SyntaxHighlighter: Add rerun if highlighting was interrupted
Added mechanism of highlighting restart when the previous
highlighting was interrupted.

Change-Id: Ic44c06442fd9f0002fed760472d5d39903e7ef50
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-06 11:52:41 +00:00
Artem Sokolovskii
95a5f01096 TextEditor: Fix folding for async syntax highlighter
- Made restoreState, ensureBlockIsUnfolded, fold, unfold and unfoldAll
functions to be called only after highlighting is done
- Improved management of foldValidator in async case
- Removed optimizations in cpphighlighter and glshighlighter.
The highlighters are async now and optimization is not necessary.
In these optimizations in the function highlightBlock the highlighting
changes not only for currentBlock but and for several next. Which is
contradict with the function name.

Change-Id: Ib413e6b982eb39d52f36c3066ff0fa8c28fbe231
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-28 11:53:02 +00:00
David Schulz
5328674479 TextEditor: simplify SyntaxHighlighterRunner interface
Change-Id: I6c8d51d8dccc91514c89267eac2cea66c87a871a
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-02-09 03:37:22 +00:00
David Schulz
e3bbace665 TextEditor: fix double delete in synchronous syntax highlighter
Change-Id: Ic4b9b78e5464613b9982814d771925d41f88bb25
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-02-08 14:24:31 +00:00
David Schulz
1cddc3d0b6 TextEditor: fix applying empty list of format changes
The block might have had some highlighting before the update, so compare
the new ranges against the one from the layout and update the layout if
the format ranges differ.

Change-Id: Ia6a0025e74fa8941b1cccc00baa93d3d37cb9ff9
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-02-08 13:32:06 +00:00
David Schulz
d651d8b41f GlslEditor: Fix crash in GlslHighlighter
since the async highlighter implementation the parent is not a
TextDocument anymore, but a QTextDocument. Pass the required mimeType
via the SyntaxHighlighterRunner now to the SyntaxHighlighter.

Change-Id: I0afcbe68719195649b4b7040416a743cb01214df
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-31 13:15:44 +00:00
David Schulz
6888c07f11 TextEditor: move struct to implementation file
Change-Id: I40ed45ff5ee1f392514e24ab17cd0c3ec7c25dc6
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-31 13:15:11 +00:00
David Schulz
f4b3b85fee TextEditor: Merge Base- and ThreadedSyntaxHighlighterRunner
Change-Id: I38ad01a895eabba99b2e554f3ae9bef85f32bb3b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-31 10:20:56 +00:00
David Schulz
0082cda044 TextEditor: Fix crash in SyntaxHighlighterRunner
Do not delete the pimpl before the thread had finished.
amends e4f5a0f50b

Change-Id: I3c0a27bd709ea759797e23f7e04e04a076012c3b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-01-17 08:46:36 +00:00
Jarek Kobus
e4f5a0f50b SyntaxHighlighterRunner: Delete private from the right thread
Before we were deleting the SyntaxHighlighterRunnerPrivate
from the caller thread. However, in case of
ThreadedSyntaxHighlighterRunner the private objects
lives in m_thread thread, so delete it from there.

Change-Id: I4e6d57ef1840a9d34ce02f2bb4423e9e47550f4d
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-15 14:28:00 +00:00
Artem Sokolovskii
03bce22663 SyntaxHighlighter: Fix leaking
Change-Id: Icd9e6cb18facbcb28692db114b952e96a66e2836
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-09 14:17:57 +00:00
Artem Sokolovskii
0618df9ea2 SyntaxHighlighter: Connect signal to this not to document
Change-Id: I4e76c4e06f385075d64b9fee1eb71d6d5212935b
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-09 14:17:49 +00:00
David Schulz
a4f9267df1 TextEditor: avoid creating an highlighter to check a type
check the type after construcing the highlighter instead and save that
information.

Change-Id: I7d942dae4be8471dba90dd266267ff7fa1b6f440
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-04 12:38:44 +00:00
David Schulz
e1535f5f39 TextEditor: simplify SyntaxHighlighterRunner::cloneDocument
Change-Id: I2cf2673bd79dd92de43392dc890f4f7482b483f6
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-04 12:38:39 +00:00
David Schulz
76ec7e1599 TextEditor: use blocknumber instead of position to identify blocks
It is used more commenly in the code for that purpose.

Change-Id: I48112d2c80485d204137da36fadbe85ad1db802b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-04 11:55:37 +00:00
David Schulz
562cf9eb4f TextEditor: simplify SyntaxHighlighterRunnerPrivate contruction
Change-Id: I40e4df9f56b67f550e74c463b2f98a15740eb43b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-04 11:54:50 +00:00
David Schulz
0f30dcee1f TextEditor: avoid unnecessary highlighter creation
Change-Id: I6e5cdabab26eb9f2d026f073c3d3db3e299a6c80
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2023-12-21 13:18:58 +00:00
Artem Sokolovskii
4a8e22e3f2 SyntaxHighlighter: Add signal that highlighting is finished
Added function syntaxInfoUpdated shows whether highlighting inProgress
or Done and signal highlightingFinished.

Change-Id: I4cf2b5cfa97d73c882e69ee1df81497ec50a81f7
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-19 11:50:24 +00:00
Artem Sokolovskii
d8561ccb2d SyntaxHighlighter: Fix tst_highlighter
Change-Id: I96c6c7b9843384d14bfa37b6bfdd494c881949af
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-18 09:00:57 +00:00
Artem Sokolovskii
3208dc92d3 SyntaxHighlighter: Remove using global fontSettings
Currently, default font settings are set inside the highlighter
runner after creating a highlighter. It prevents to call
TextEditorSettings::fontSettings() from non-main threads.

Change-Id: I0c806f0f586c67749cb2964bebdf2bf3c58a5302
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-14 13:28:22 +00:00
Artem Sokolovskii
e396f84d10 SyntaxHighlighter: Move generic highlighter to separate thread
Adds a full copy of KSyntaxHighlighting::Repository class
to the Highlighter class, enabling the relocation of the
Highlighter class to a separate thread. This adjustment ensures
that all Definitions come from the copy of the repository, making
them immutable from external code.

The "reload Definition" function stays supported, as triggering
it results in the recreation of the highlighter for the document,
thereby reconstructing the Repository class.

Change-Id: Id7a4d865228c7e7e20e4770601a3fde55b8a6513
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-12 13:03:59 +00:00
Artem Sokolovskii
62ea85ee6a SyntaxHighlighter: Move SyntaxHighlighter to separate thread
This change involves the relocation of SyntaxHighlighter processing
to another thread. The core idea is to create a duplicate of the
original TextDocument using SyntaxHighlighterRunnerPrivate::cloneDocument.
A new SyntaxHighlighter is then instantiated by SyntaxHighLighterCreator
for the cloned document. The entire SyntaxHighLighterCreator class is
moved to a new thread, where it performs highlighting on the cloned
document. Upon completion of the highlighting process, the resultsReady
signal is emitted, and the updated highlighting data is applied to the
original document.

This shift of SyntaxHighlighter to another thread enhances the user
experience by preventing UI slowdowns during the highlighting process.

- Introduction of BaseSyntaxHighlighterRunner as an interface class for
future *SyntaxHighlighterRunner.
- Inclusion of DirectSyntaxHighlighterRunner class for performing
highlighting in the main thread, suitable for syntax highlighters
that cannot be moved to another thread.
- Introduction of ThreadedSyntaxHighlighterRunner class for highlighting
in a separate thread, preventing UI blocking during the process.
- Addition of Result data to the SyntaxHighlighter class to facilitate
data exchange between threads.

Task-number: QTCREATORBUG-28727
Change-Id: I4b6a38d15f5ec9b8828055d38d2a0c6f21a657b4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-11 09:55:02 +00:00