forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -103,7 +103,7 @@ ClangModelManagerSupport::ClangModelManagerSupport()
|
|||||||
connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject,
|
connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject,
|
||||||
this, &ClangModelManagerSupport::onAboutToRemoveProject);
|
this, &ClangModelManagerSupport::onAboutToRemoveProject);
|
||||||
|
|
||||||
CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings().data();
|
CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings();
|
||||||
connect(settings, &CppTools::CppCodeModelSettings::clangDiagnosticConfigsInvalidated,
|
connect(settings, &CppTools::CppCodeModelSettings::clangDiagnosticConfigsInvalidated,
|
||||||
this, &ClangModelManagerSupport::onDiagnosticConfigsInvalidated);
|
this, &ClangModelManagerSupport::onDiagnosticConfigsInvalidated);
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,7 @@ ClangProjectSettingsWidget::ClangProjectSettingsWidget(ProjectExplorer::Project
|
|||||||
|
|
||||||
connect(&m_projectSettings, &ClangProjectSettings::changed,
|
connect(&m_projectSettings, &ClangProjectSettings::changed,
|
||||||
this, &ClangProjectSettingsWidget::syncWidgets);
|
this, &ClangProjectSettingsWidget::syncWidgets);
|
||||||
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
connect(CppTools::codeModelSettings(), &CppTools::CppCodeModelSettings::changed,
|
||||||
this, &ClangProjectSettingsWidget::syncOtherWidgetsToComboBox);
|
this, &ClangProjectSettingsWidget::syncOtherWidgetsToComboBox);
|
||||||
|
|
||||||
syncWidgets();
|
syncWidgets();
|
||||||
|
@@ -127,8 +127,8 @@ void disableDiagnosticInConfig(ClangDiagnosticConfig &config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangDiagnosticConfig diagnosticConfig(ClangProjectSettings &projectSettings,
|
ClangDiagnosticConfig diagnosticConfig(const ClangProjectSettings &projectSettings,
|
||||||
CppCodeModelSettings &globalSettings)
|
const CppCodeModelSettings &globalSettings)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Project *project = projectForCurrentEditor();
|
ProjectExplorer::Project *project = projectForCurrentEditor();
|
||||||
QTC_ASSERT(project, return {});
|
QTC_ASSERT(project, return {});
|
||||||
@@ -152,7 +152,7 @@ bool isDiagnosticConfigChangable(ProjectExplorer::Project *project,
|
|||||||
|
|
||||||
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
||||||
project);
|
project);
|
||||||
const QSharedPointer<CppCodeModelSettings> globalSettings = codeModelSettings();
|
const CppCodeModelSettings *globalSettings = codeModelSettings();
|
||||||
const ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
const ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
||||||
|
|
||||||
if (config.clangTidyMode() == ClangDiagnosticConfig::TidyMode::UseConfigFile
|
if (config.clangTidyMode() == ClangDiagnosticConfig::TidyMode::UseConfigFile
|
||||||
@@ -170,7 +170,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticConta
|
|||||||
// Get settings
|
// Get settings
|
||||||
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
||||||
project);
|
project);
|
||||||
const QSharedPointer<CppCodeModelSettings> globalSettings = codeModelSettings();
|
CppCodeModelSettings *globalSettings = codeModelSettings();
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
||||||
|
@@ -172,7 +172,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
{
|
{
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
const CppCodeModelSettings *cms = CppToolsPlugin::instance()->codeModelSettings();
|
||||||
|
|
||||||
BaseEditorDocumentParser::Configuration config = m_parser->configuration();
|
BaseEditorDocumentParser::Configuration config = m_parser->configuration();
|
||||||
config.usePrecompiledHeaders = cms->pchUsage() != CppCodeModelSettings::PchUse_None;
|
config.usePrecompiledHeaders = cms->pchUsage() != CppCodeModelSettings::PchUse_None;
|
||||||
|
@@ -44,7 +44,7 @@ class CppCodeModelSettingsWidget final : public Core::IOptionsPageWidget
|
|||||||
Q_DECLARE_TR_FUNCTIONS(CppTools::Internal::CppCodeModelSettingsWidget)
|
Q_DECLARE_TR_FUNCTIONS(CppTools::Internal::CppCodeModelSettingsWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppCodeModelSettingsWidget(const QSharedPointer<CppCodeModelSettings> &s);
|
CppCodeModelSettingsWidget(CppCodeModelSettings *s);
|
||||||
~CppCodeModelSettingsWidget() override;
|
~CppCodeModelSettingsWidget() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -57,10 +57,10 @@ private:
|
|||||||
bool applyClangCodeModelWidgetsToSettings() const;
|
bool applyClangCodeModelWidgetsToSettings() const;
|
||||||
|
|
||||||
Ui::CppCodeModelSettingsPage *m_ui = nullptr;
|
Ui::CppCodeModelSettingsPage *m_ui = nullptr;
|
||||||
QSharedPointer<CppCodeModelSettings> m_settings;
|
CppCodeModelSettings *m_settings = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(const QSharedPointer<CppCodeModelSettings> &s)
|
CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s)
|
||||||
: m_ui(new Ui::CppCodeModelSettingsPage)
|
: m_ui(new Ui::CppCodeModelSettingsPage)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
@@ -177,7 +177,7 @@ bool CppCodeModelSettingsWidget::applyGeneralWidgetsToSettings() const
|
|||||||
return settingsChanged;
|
return settingsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings)
|
CppCodeModelSettingsPage::CppCodeModelSettingsPage(CppCodeModelSettings *settings)
|
||||||
{
|
{
|
||||||
setId(Constants::CPP_CODE_MODEL_SETTINGS_ID);
|
setId(Constants::CPP_CODE_MODEL_SETTINGS_ID);
|
||||||
setDisplayName(CppCodeModelSettingsWidget::tr("Code Model"));
|
setDisplayName(CppCodeModelSettingsWidget::tr("Code Model"));
|
||||||
|
@@ -35,7 +35,7 @@ namespace Internal {
|
|||||||
class CppCodeModelSettingsPage final : public Core::IOptionsPage
|
class CppCodeModelSettingsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings);
|
explicit CppCodeModelSettingsPage(CppCodeModelSettings *settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal namespace
|
} // Internal namespace
|
||||||
|
@@ -81,14 +81,12 @@ class CppToolsPluginPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppToolsPluginPrivate()
|
CppToolsPluginPrivate()
|
||||||
: m_codeModelSettings(new CppCodeModelSettings)
|
|
||||||
{
|
{
|
||||||
StringTable::initialize();
|
StringTable::initialize();
|
||||||
CppModelManager::createCppModelManager(m_instance);
|
CppModelManager::createCppModelManager(m_instance);
|
||||||
m_settings = new CppToolsSettings(m_instance); // force registration of cpp tools settings
|
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_cppFileSettingsPage = new CppFileSettingsPage(m_instance->m_fileSettings);
|
||||||
m_cppCodeModelSettingsPage = new CppCodeModelSettingsPage(m_codeModelSettings);
|
|
||||||
m_cppCodeStyleSettingsPage = new CppCodeStyleSettingsPage;
|
m_cppCodeStyleSettingsPage = new CppCodeStyleSettingsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,16 +94,15 @@ public:
|
|||||||
{
|
{
|
||||||
StringTable::destroy();
|
StringTable::destroy();
|
||||||
delete m_cppFileSettingsPage;
|
delete m_cppFileSettingsPage;
|
||||||
delete m_cppCodeModelSettingsPage;
|
|
||||||
if (m_cppCodeStyleSettingsPage)
|
if (m_cppCodeStyleSettingsPage)
|
||||||
delete m_cppCodeStyleSettingsPage;
|
delete m_cppCodeStyleSettingsPage;
|
||||||
ExtensionSystem::PluginManager::removeObject(&m_cppProjectUpdaterFactory);
|
ExtensionSystem::PluginManager::removeObject(&m_cppProjectUpdaterFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> m_codeModelSettings;
|
CppCodeModelSettings m_codeModelSettings;
|
||||||
CppToolsSettings *m_settings = nullptr;
|
CppToolsSettings *m_settings = nullptr;
|
||||||
CppFileSettingsPage *m_cppFileSettingsPage = nullptr;
|
CppFileSettingsPage *m_cppFileSettingsPage = nullptr;
|
||||||
CppCodeModelSettingsPage *m_cppCodeModelSettingsPage = nullptr;
|
CppCodeModelSettingsPage m_cppCodeModelSettingsPage{&m_codeModelSettings};
|
||||||
QPointer<CppCodeStyleSettingsPage> m_cppCodeStyleSettingsPage = nullptr;
|
QPointer<CppCodeStyleSettingsPage> m_cppCodeStyleSettingsPage = nullptr;
|
||||||
CppProjectUpdaterFactory m_cppProjectUpdaterFactory;
|
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");
|
qWarning("Unable to apply cpp suffixes to mime database (cpp mime types not found).\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> CppToolsPlugin::codeModelSettings() const
|
CppCodeModelSettings *CppToolsPlugin::codeModelSettings()
|
||||||
{
|
{
|
||||||
return d->m_codeModelSettings;
|
return &d->m_codeModelSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::switchHeaderSource()
|
void CppToolsPlugin::switchHeaderSource()
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||||
void extensionsInitialized() final;
|
void extensionsInitialized() final;
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> codeModelSettings() const;
|
CppCodeModelSettings *codeModelSettings();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void switchHeaderSource();
|
void switchHeaderSource();
|
||||||
|
@@ -294,14 +294,14 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> codeModelSettings()
|
CppCodeModelSettings *codeModelSettings()
|
||||||
{
|
{
|
||||||
return CppTools::Internal::CppToolsPlugin::instance()->codeModelSettings();
|
return CppTools::Internal::CppToolsPlugin::instance()->codeModelSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
int indexerFileSizeLimitInMb()
|
int indexerFileSizeLimitInMb()
|
||||||
{
|
{
|
||||||
const QSharedPointer<CppCodeModelSettings> settings = codeModelSettings();
|
const CppCodeModelSettings *settings = codeModelSettings();
|
||||||
QTC_ASSERT(settings, return -1);
|
QTC_ASSERT(settings, return -1);
|
||||||
|
|
||||||
if (settings->skipIndexingBigFiles())
|
if (settings->skipIndexingBigFiles())
|
||||||
@@ -335,7 +335,7 @@ bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb)
|
|||||||
|
|
||||||
UsePrecompiledHeaders getPchUsage()
|
UsePrecompiledHeaders getPchUsage()
|
||||||
{
|
{
|
||||||
const QSharedPointer<CppCodeModelSettings> cms = codeModelSettings();
|
const CppCodeModelSettings *cms = codeModelSettings();
|
||||||
if (cms->pchUsage() == CppCodeModelSettings::PchUse_None)
|
if (cms->pchUsage() == CppCodeModelSettings::PchUse_None)
|
||||||
return UsePrecompiledHeaders::No;
|
return UsePrecompiledHeaders::No;
|
||||||
return UsePrecompiledHeaders::Yes;
|
return UsePrecompiledHeaders::Yes;
|
||||||
|
@@ -75,7 +75,7 @@ QString CPPTOOLS_EXPORT correspondingHeaderOrSource(const QString &fileName, boo
|
|||||||
void CPPTOOLS_EXPORT switchHeaderSource();
|
void CPPTOOLS_EXPORT switchHeaderSource();
|
||||||
|
|
||||||
class CppCodeModelSettings;
|
class CppCodeModelSettings;
|
||||||
QSharedPointer<CppCodeModelSettings> CPPTOOLS_EXPORT codeModelSettings();
|
CppCodeModelSettings CPPTOOLS_EXPORT *codeModelSettings();
|
||||||
|
|
||||||
UsePrecompiledHeaders CPPTOOLS_EXPORT getPchUsage();
|
UsePrecompiledHeaders CPPTOOLS_EXPORT getPchUsage();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user