Fix a crash when loading the qt4projectmangerplugin.

This crash can happen when enabling/disabling a certain combination
of plugins and restarting.

There was a null pointer de-reference that was occurring because the
qt4projectmanagerplugin was referencing an action that it believed
to have been registered by the texteditorplugin when it was initialized.

However, apparently the texteditorplugin was not initializing its actions
at plugin initialization, but rather when 'extensionsInitialized' was called.
I do not know the call graph for when this is to be called, but I encountered
at least one situation where the qt4projectmanagerplugin was being initialized
before this.

Change-Id: Iede1831e0ac9c92b80a079157e1bdc8c66473470
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Adam Treat
2012-01-27 07:52:03 -05:00
committed by Eike Ziller
parent 6b1b47d83c
commit 01d8907ea9
2 changed files with 6 additions and 3 deletions

View File

@@ -330,7 +330,7 @@ QMenuBar *ActionContainerPrivate::menuBar() const
bool ActionContainerPrivate::canAddAction(Command *action) const
{
return (action->action() != 0);
return action && action->action();
}
void ActionContainerPrivate::scheduleUpdate()

View File

@@ -163,13 +163,16 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
m_outlineFactory = new OutlineFactory;
addAutoReleasedObject(m_outlineFactory);
// We have to initialize the actions because other plugins that
// depend upon the texteditorplugin expect that actions will be
// registered in the action manager at plugin initialization time.
m_editorFactory->actionHandler()->initializeActions();
return true;
}
void TextEditorPlugin::extensionsInitialized()
{
m_editorFactory->actionHandler()->initializeActions();
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
m_searchResultWindow = Find::SearchResultWindow::instance();