diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index 7907abdfedf..aed9bcaadb3 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -103,7 +103,7 @@ ClangModelManagerSupport::ClangModelManagerSupport() connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject, this, &ClangModelManagerSupport::onAboutToRemoveProject); - CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings().data(); + CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings(); connect(settings, &CppTools::CppCodeModelSettings::clangDiagnosticConfigsInvalidated, this, &ClangModelManagerSupport::onDiagnosticConfigsInvalidated); } diff --git a/src/plugins/clangcodemodel/clangprojectsettingswidget.cpp b/src/plugins/clangcodemodel/clangprojectsettingswidget.cpp index 9987b12179f..e5187defbed 100644 --- a/src/plugins/clangcodemodel/clangprojectsettingswidget.cpp +++ b/src/plugins/clangcodemodel/clangprojectsettingswidget.cpp @@ -88,7 +88,7 @@ ClangProjectSettingsWidget::ClangProjectSettingsWidget(ProjectExplorer::Project connect(&m_projectSettings, &ClangProjectSettings::changed, this, &ClangProjectSettingsWidget::syncWidgets); - connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed, + connect(CppTools::codeModelSettings(), &CppTools::CppCodeModelSettings::changed, this, &ClangProjectSettingsWidget::syncOtherWidgetsToComboBox); syncWidgets(); diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index c23ab56e956..8a8639802db 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -127,8 +127,8 @@ void disableDiagnosticInConfig(ClangDiagnosticConfig &config, } } -ClangDiagnosticConfig diagnosticConfig(ClangProjectSettings &projectSettings, - CppCodeModelSettings &globalSettings) +ClangDiagnosticConfig diagnosticConfig(const ClangProjectSettings &projectSettings, + const CppCodeModelSettings &globalSettings) { ProjectExplorer::Project *project = projectForCurrentEditor(); QTC_ASSERT(project, return {}); @@ -152,7 +152,7 @@ bool isDiagnosticConfigChangable(ProjectExplorer::Project *project, ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings( project); - const QSharedPointer globalSettings = codeModelSettings(); + const CppCodeModelSettings *globalSettings = codeModelSettings(); const ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings); if (config.clangTidyMode() == ClangDiagnosticConfig::TidyMode::UseConfigFile @@ -170,7 +170,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticConta // Get settings ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings( project); - const QSharedPointer globalSettings = codeModelSettings(); + CppCodeModelSettings *globalSettings = codeModelSettings(); // Get config ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings); diff --git a/src/plugins/cpptools/builtineditordocumentprocessor.cpp b/src/plugins/cpptools/builtineditordocumentprocessor.cpp index 5c78dbbdf8d..408c6e7b15a 100644 --- a/src/plugins/cpptools/builtineditordocumentprocessor.cpp +++ b/src/plugins/cpptools/builtineditordocumentprocessor.cpp @@ -172,7 +172,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor( { using namespace Internal; - QSharedPointer cms = CppToolsPlugin::instance()->codeModelSettings(); + const CppCodeModelSettings *cms = CppToolsPlugin::instance()->codeModelSettings(); BaseEditorDocumentParser::Configuration config = m_parser->configuration(); config.usePrecompiledHeaders = cms->pchUsage() != CppCodeModelSettings::PchUse_None; diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.cpp b/src/plugins/cpptools/cppcodemodelsettingspage.cpp index cca9f76a647..5b259d7ab54 100644 --- a/src/plugins/cpptools/cppcodemodelsettingspage.cpp +++ b/src/plugins/cpptools/cppcodemodelsettingspage.cpp @@ -44,7 +44,7 @@ class CppCodeModelSettingsWidget final : public Core::IOptionsPageWidget Q_DECLARE_TR_FUNCTIONS(CppTools::Internal::CppCodeModelSettingsWidget) public: - CppCodeModelSettingsWidget(const QSharedPointer &s); + CppCodeModelSettingsWidget(CppCodeModelSettings *s); ~CppCodeModelSettingsWidget() override; private: @@ -57,10 +57,10 @@ private: bool applyClangCodeModelWidgetsToSettings() const; Ui::CppCodeModelSettingsPage *m_ui = nullptr; - QSharedPointer m_settings; + CppCodeModelSettings *m_settings = nullptr; }; -CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(const QSharedPointer &s) +CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s) : m_ui(new Ui::CppCodeModelSettingsPage) { m_ui->setupUi(this); @@ -177,7 +177,7 @@ bool CppCodeModelSettingsWidget::applyGeneralWidgetsToSettings() const return settingsChanged; } -CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer &settings) +CppCodeModelSettingsPage::CppCodeModelSettingsPage(CppCodeModelSettings *settings) { setId(Constants::CPP_CODE_MODEL_SETTINGS_ID); setDisplayName(CppCodeModelSettingsWidget::tr("Code Model")); diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.h b/src/plugins/cpptools/cppcodemodelsettingspage.h index 7ca9b64f285..dd297af020c 100644 --- a/src/plugins/cpptools/cppcodemodelsettingspage.h +++ b/src/plugins/cpptools/cppcodemodelsettingspage.h @@ -35,7 +35,7 @@ namespace Internal { class CppCodeModelSettingsPage final : public Core::IOptionsPage { public: - explicit CppCodeModelSettingsPage(QSharedPointer &settings); + explicit CppCodeModelSettingsPage(CppCodeModelSettings *settings); }; } // Internal namespace diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index d0d486e201b..98a476569ae 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() diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h index 8035c08785e..d52b046eabb 100644 --- a/src/plugins/cpptools/cpptoolsplugin.h +++ b/src/plugins/cpptools/cpptoolsplugin.h @@ -70,7 +70,7 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage) final; void extensionsInitialized() final; - QSharedPointer codeModelSettings() const; + CppCodeModelSettings *codeModelSettings(); public slots: void switchHeaderSource(); diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp index 4769260d54b..37a00673b3e 100644 --- a/src/plugins/cpptools/cpptoolsreuse.cpp +++ b/src/plugins/cpptools/cpptoolsreuse.cpp @@ -294,14 +294,14 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen return nullptr; } -QSharedPointer codeModelSettings() +CppCodeModelSettings *codeModelSettings() { return CppTools::Internal::CppToolsPlugin::instance()->codeModelSettings(); } int indexerFileSizeLimitInMb() { - const QSharedPointer settings = codeModelSettings(); + const CppCodeModelSettings *settings = codeModelSettings(); QTC_ASSERT(settings, return -1); if (settings->skipIndexingBigFiles()) @@ -335,7 +335,7 @@ bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb) UsePrecompiledHeaders getPchUsage() { - const QSharedPointer cms = codeModelSettings(); + const CppCodeModelSettings *cms = codeModelSettings(); if (cms->pchUsage() == CppCodeModelSettings::PchUse_None) return UsePrecompiledHeaders::No; return UsePrecompiledHeaders::Yes; diff --git a/src/plugins/cpptools/cpptoolsreuse.h b/src/plugins/cpptools/cpptoolsreuse.h index 9ad97df0592..afab4a46845 100644 --- a/src/plugins/cpptools/cpptoolsreuse.h +++ b/src/plugins/cpptools/cpptoolsreuse.h @@ -75,7 +75,7 @@ QString CPPTOOLS_EXPORT correspondingHeaderOrSource(const QString &fileName, boo void CPPTOOLS_EXPORT switchHeaderSource(); class CppCodeModelSettings; -QSharedPointer CPPTOOLS_EXPORT codeModelSettings(); +CppCodeModelSettings CPPTOOLS_EXPORT *codeModelSettings(); UsePrecompiledHeaders CPPTOOLS_EXPORT getPchUsage();