aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/syntaxhighlighter.cpp
diff options
context:
space:
mode:
authorArtem Sokolovskii <artem.sokolovskii@qt.io>2023-05-19 13:03:01 +0200
committerArtem Sokolovskii <artem.sokolovskii@qt.io>2023-11-21 15:27:08 +0000
commit84275809b4182faccced04e84de27689fba49146 (patch)
tree72f79e2b2f6c78b48e5649c75aa9901b311d5e3f /src/plugins/texteditor/syntaxhighlighter.cpp
parent6910408f35145c60e3a78ce1a0ed7ce24bc801d4 (diff)
SyntaxHighlighter: Make setChangeNumbers private function
Made setChangeNumbers private function in BaseAnnotationHighlighter and remove usage in other places. Moved annotationChanges to BaseAnnotationHighlighterPrivate from VcsBaseEditorWidget. This was done to move all instances of TextEditor::SyntaxHighlighter. In this regards only the public API of TextEditor::SyntaxHighlighter should be available from children and no other additional functions. Change-Id: Ibece9476a810e13c8722839820d5c575b0808f03 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/texteditor/syntaxhighlighter.cpp')
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index 24a96522b3..36c4549487 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -308,6 +308,9 @@ SyntaxHighlighter::~SyntaxHighlighter()
void SyntaxHighlighter::setDocument(QTextDocument *doc)
{
Q_D(SyntaxHighlighter);
+ if (d->doc == doc)
+ return;
+
if (d->doc) {
disconnect(d->doc, &QTextDocument::contentsChange, this, &SyntaxHighlighter::reformatBlocks);
@@ -317,7 +320,9 @@ void SyntaxHighlighter::setDocument(QTextDocument *doc)
blk.layout()->clearFormats();
cursor.endEditBlock();
}
+ QTextDocument *oldDoc = d->doc;
d->doc = doc;
+ documentChanged(oldDoc, d->doc);
if (d->doc) {
if (!d->noAutomaticHighlighting) {
connect(d->doc, &QTextDocument::contentsChange, this, &SyntaxHighlighter::reformatBlocks);