forked from qt-creator/qt-creator
CppTools: Fix crash when loading pre 4.11 settings
If pre 4.11 settings are present, this might lead to updated settings being written at startup. The code that writes settings indirectly uses the CppToolsPluginPrivate instance via the "d" member of CppToolsPlugin. So this code path crashes if triggered in the constructor of CppToolsPluginPrivate, since at that point "d" cannot be assigned yet. Separate construction and initialization to avoid this. Fixes: QTCREATORBUG-23916 Change-Id: I0cb8a08bd9aa051679b71b06f569c44d2faab5a8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -80,10 +80,9 @@ static QHash<QString, QString> m_headerSourceMapping;
|
||||
class CppToolsPluginPrivate
|
||||
{
|
||||
public:
|
||||
CppToolsPluginPrivate()
|
||||
{
|
||||
m_codeModelSettings.fromSettings(ICore::settings());
|
||||
}
|
||||
CppToolsPluginPrivate() {}
|
||||
|
||||
void initialize() { m_codeModelSettings.fromSettings(ICore::settings()); }
|
||||
|
||||
~CppToolsPluginPrivate()
|
||||
{
|
||||
@@ -165,6 +164,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
Q_UNUSED(error)
|
||||
|
||||
d = new CppToolsPluginPrivate;
|
||||
d->initialize();
|
||||
|
||||
JsExpander::registerGlobalObject<CppToolsJsExtension>("Cpp");
|
||||
ExtensionSystem::PluginManager::addObject(&d->m_cppProjectUpdaterFactory);
|
||||
|
Reference in New Issue
Block a user