summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-09-18 12:46:48 +0200
committerEike Ziller <eike.ziller@qt.io>2018-09-19 06:36:55 +0000
commit6ea686faa958e6b98fcdfdc48151552812156688 (patch)
tree839c4e5ef75449b6b56efc37b5acb8e604d664ac
parentdd0347d1ee0f077dc5ad03553b7cdece3a881d27 (diff)
downloadqt-creator-6ea686faa958e6b98fcdfdc48151552812156688.tar.gz
Avoid accessing global font settings from syntax highlighters
Change-Id: Ic015f7449351166ec41a7745355ddc63504f6442 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/texteditor/generichighlighter/highlighter.cpp2
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.cpp8
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.h1
-rw-r--r--src/plugins/vcsbase/baseannotationhighlighter.cpp2
4 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/texteditor/generichighlighter/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp
index 8ece3f462e..3476a637b2 100644
--- a/src/plugins/texteditor/generichighlighter/highlighter.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp
@@ -569,7 +569,7 @@ void Highlighter::applyFormat(int offset,
// think this approach would fit better. If there are other ideas...
QBrush bg = format.background();
if (bg.style() == Qt::NoBrush)
- bg = TextEditorSettings::fontSettings().toTextCharFormat(C_TEXT).background();
+ bg = fontSettings().toTextCharFormat(C_TEXT).background();
if (itemData->color().isValid() && isReadableOn(bg.color(), itemData->color()))
format.setForeground(itemData->color());
if (itemData->isItalicSpecified())
diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index 621df4f236..87ca923f4e 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -66,6 +66,7 @@ public:
void applyFormatChanges(int from, int charsRemoved, int charsAdded);
void updateFormats(const FontSettings &fontSettings);
+ FontSettings fontSettings;
QVector<QTextCharFormat> formatChanges;
QTextBlock currentBlock;
bool rehighlightPending = false;
@@ -765,6 +766,12 @@ void SyntaxHighlighter::setFontSettings(const FontSettings &fontSettings)
Q_D(SyntaxHighlighter);
d->updateFormats(fontSettings);
}
+
+FontSettings SyntaxHighlighter::fontSettings() const
+{
+ Q_D(const SyntaxHighlighter);
+ return d->fontSettings;
+}
/*!
The syntax highlighter is not anymore reacting to the text document if \a noAutmatic is
\c true.
@@ -836,6 +843,7 @@ void SyntaxHighlighter::highlightBlock(const QString &text)
void SyntaxHighlighterPrivate::updateFormats(const FontSettings &fontSettings)
{
+ this->fontSettings = fontSettings;
// C_TEXT is handled by text editor's foreground and background color,
// so use empty format for that
for (const auto &pair : qAsConst(formatCategories)) {
diff --git a/src/plugins/texteditor/syntaxhighlighter.h b/src/plugins/texteditor/syntaxhighlighter.h
index b67a277d2c..134768b167 100644
--- a/src/plugins/texteditor/syntaxhighlighter.h
+++ b/src/plugins/texteditor/syntaxhighlighter.h
@@ -69,6 +69,7 @@ public:
// Don't call in constructors of derived classes
virtual void setFontSettings(const TextEditor::FontSettings &fontSettings);
+ TextEditor::FontSettings fontSettings() const;
void setNoAutomaticHighlighting(bool noAutomatic);
diff --git a/src/plugins/vcsbase/baseannotationhighlighter.cpp b/src/plugins/vcsbase/baseannotationhighlighter.cpp
index 6b3154ab27..32a0377040 100644
--- a/src/plugins/vcsbase/baseannotationhighlighter.cpp
+++ b/src/plugins/vcsbase/baseannotationhighlighter.cpp
@@ -64,7 +64,7 @@ public:
void BaseAnnotationHighlighterPrivate::updateOtherFormats()
{
- m_background = TextEditor::TextEditorSettings::fontSettings()
+ m_background = q->fontSettings()
.toTextCharFormat(TextEditor::C_TEXT)
.brushProperty(QTextFormat::BackgroundBrush)
.color();