From 36f23df6c32330ecaf2b82002a3a14fb7fb55cc5 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 3 Feb 2020 11:13:27 +0100 Subject: CppTools: Use unshared object for CppCodeModelSettings There's nothing shared here, only ever one copy. Ideally, this should be const outside CppToolsPlugin, but some settings are modified directly. Change-Id: I775b9151a244b3cc44d28bc992a041c42d234a18 Reviewed-by: Christian Stenger --- src/plugins/cpptools/cpptoolsplugin.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp') diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index d0d486e201..98a476569a 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -81,14 +81,12 @@ class CppToolsPluginPrivate { public: CppToolsPluginPrivate() - : m_codeModelSettings(new CppCodeModelSettings) { StringTable::initialize(); CppModelManager::createCppModelManager(m_instance); m_settings = new CppToolsSettings(m_instance); // force registration of cpp tools settings - m_codeModelSettings->fromSettings(ICore::settings()); + m_codeModelSettings.fromSettings(ICore::settings()); m_cppFileSettingsPage = new CppFileSettingsPage(m_instance->m_fileSettings); - m_cppCodeModelSettingsPage = new CppCodeModelSettingsPage(m_codeModelSettings); m_cppCodeStyleSettingsPage = new CppCodeStyleSettingsPage; } @@ -96,16 +94,15 @@ public: { StringTable::destroy(); delete m_cppFileSettingsPage; - delete m_cppCodeModelSettingsPage; if (m_cppCodeStyleSettingsPage) delete m_cppCodeStyleSettingsPage; ExtensionSystem::PluginManager::removeObject(&m_cppProjectUpdaterFactory); } - QSharedPointer m_codeModelSettings; + CppCodeModelSettings m_codeModelSettings; CppToolsSettings *m_settings = nullptr; CppFileSettingsPage *m_cppFileSettingsPage = nullptr; - CppCodeModelSettingsPage *m_cppCodeModelSettingsPage = nullptr; + CppCodeModelSettingsPage m_cppCodeModelSettingsPage{&m_codeModelSettings}; QPointer m_cppCodeStyleSettingsPage = nullptr; CppProjectUpdaterFactory m_cppProjectUpdaterFactory; }; @@ -231,9 +228,9 @@ void CppToolsPlugin::extensionsInitialized() qWarning("Unable to apply cpp suffixes to mime database (cpp mime types not found).\n"); } -QSharedPointer CppToolsPlugin::codeModelSettings() const +CppCodeModelSettings *CppToolsPlugin::codeModelSettings() { - return d->m_codeModelSettings; + return &d->m_codeModelSettings; } void CppToolsPlugin::switchHeaderSource() -- cgit v1.2.1