aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/texteditorsettings.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2024-02-15 09:38:15 +0100
committerhjk <hjk@qt.io>2024-02-15 10:00:54 +0000
commit41131eadaa73d5a70620d0056e14d26005291b55 (patch)
treed6640da21ac304b16b4699075cd3e13269e39a33 /src/plugins/texteditor/texteditorsettings.cpp
parentc6aeb2cde1f992f2e0044f5c10f0652818af8da3 (diff)
TextEditor: Drop TextEditorSettings::m_instance
This can be null when accessed too early. Using the function-static global instance directly ensures initialization. There is more simplification potential in this area, but I'd leave that for master. Change-Id: Ide35f4119e9fbcb392d1abac180ef46c02c16b87 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/texteditor/texteditorsettings.cpp')
-rw-r--r--src/plugins/texteditor/texteditorsettings.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index ca499f613b..e3f96fa167 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -418,12 +418,9 @@ FormatDescriptions TextEditorSettingsPrivate::initialFormats()
static TextEditorSettingsPrivate *d = nullptr;
-static TextEditorSettings *m_instance = nullptr;
TextEditorSettings::TextEditorSettings()
{
- QTC_ASSERT(!m_instance, return);
- m_instance = this;
d = new Internal::TextEditorSettingsPrivate;
// Note: default background colors are coming from FormatDescription::background()
@@ -453,13 +450,11 @@ TextEditorSettings::TextEditorSettings()
TextEditorSettings::~TextEditorSettings()
{
delete d;
-
- m_instance = nullptr;
}
TextEditorSettings *TextEditorSettings::instance()
{
- return m_instance;
+ return &textEditorSettings();
}
const FontSettings &TextEditorSettings::fontSettings()
@@ -578,7 +573,7 @@ static void setFontZoom(int zoom)
{
d->m_fontSettings.setFontZoom(zoom);
d->m_fontSettings.toSettings(Core::ICore::settings());
- emit m_instance->fontSettingsChanged(d->m_fontSettings);
+ emit textEditorSettings().fontSettingsChanged(d->m_fontSettings);
}
int TextEditorSettings::increaseFontZoom(int step)