diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 46b4f76bc7a..984d522f340 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -272,16 +272,15 @@ void BaseTextDocument::setFontSettings(const FontSettings &fontSettings) emit fontSettingsChanged(); } -void BaseTextDocument::ensureFontSettingsApplied() +void BaseTextDocument::triggerPendingUpdates() { - if (!d->m_fontSettingsNeedsApply) - return; - d->m_fontSettingsNeedsApply = false; - applyFontSettings(); + if (d->m_fontSettingsNeedsApply) + applyFontSettings(); } void BaseTextDocument::applyFontSettings() { + d->m_fontSettingsNeedsApply = false; if (d->m_highlighter) { d->m_highlighter->setFontSettings(d->m_fontSettings); d->m_highlighter->rehighlight(); diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 2e41cc370e9..fd65a3c638c 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -113,7 +113,7 @@ public: bool reload(QString *errorString, QTextCodec *codec); void cleanWhitespace(const QTextCursor &cursor); - void ensureFontSettingsApplied(); + void triggerPendingUpdates(); public slots: void setTabSettings(const TextEditor::TabSettings &tabSettings); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 65779aeecec..03d1db57f06 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -5337,24 +5337,28 @@ void BaseTextEditorWidget::unCommentSelection() void BaseTextEditorWidget::showEvent(QShowEvent* e) { - if (d->m_fontSettingsNeedsApply) { - applyFontSettings(); - d->m_fontSettingsNeedsApply = false; - } + triggerPendingUpdates(); QPlainTextEdit::showEvent(e); } void BaseTextEditorWidget::applyFontSettingsDelayed() { + d->m_fontSettingsNeedsApply = true; if (isVisible()) + triggerPendingUpdates(); +} + +void BaseTextEditorWidget::triggerPendingUpdates() +{ + if (d->m_fontSettingsNeedsApply) applyFontSettings(); - else - d->m_fontSettingsNeedsApply = true; + baseTextDocument()->triggerPendingUpdates(); } void BaseTextEditorWidget::applyFontSettings() { + d->m_fontSettingsNeedsApply = false; const FontSettings &fs = baseTextDocument()->fontSettings(); const QTextCharFormat textFormat = fs.toTextCharFormat(C_TEXT); const QTextCharFormat selectionFormat = fs.toTextCharFormat(C_SELECTION); @@ -5388,8 +5392,6 @@ void BaseTextEditorWidget::applyFontSettings() slotUpdateExtraAreaWidth(); // Adjust to new font width updateCurrentLineHighlight(); // Make sure it takes the new color - - baseTextDocument()->ensureFontSettingsApplied(); } void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds) diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 864955e69b7..b1cff82863d 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -343,6 +343,7 @@ private: protected: virtual BaseTextEditor *createEditor() = 0; + virtual void triggerPendingUpdates(); virtual void applyFontSettings(); private slots: