Commit 0d5211cc authored by con's avatar con

Prevent crash when closing Qt Creator while cdb session is running.

The debugger plugin opens an editor in this case, leading to fakevim and
cppeditor crashing.
This commit doesn't fix the problem's source, but adds safeguards that
are sensible anyhow: FakeVim should not register with editors during
shutdown, and CppEditor should not unconditionally assume an existing
editor manager in the destructor.

Reviewed-by: Friedemann Kleint
parent ffbbca4c
......@@ -454,6 +454,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
EditorManager::~EditorManager()
{
m_instance = 0;
if (m_d->m_core) {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
if (m_d->m_coreListener) {
......
......@@ -432,7 +432,8 @@ CPPEditor::CPPEditor(QWidget *parent)
CPPEditor::~CPPEditor()
{
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
if (Core::EditorManager *em = Core::EditorManager::instance())
em->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
m_semanticHighlighter->abort();
m_semanticHighlighter->wait();
......
......@@ -491,6 +491,7 @@ public:
friend class FakeVimExCommandsPage;
bool initialize();
void onCoreAboutToClose();
void aboutToShutdown();
private slots:
......@@ -586,6 +587,13 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate()
m_fakeVimExCommandsPage = 0;
}
void FakeVimPluginPrivate::onCoreAboutToClose()
{
// don't attach to editors any more
disconnect(editorManager(), SIGNAL(editorOpened(Core::IEditor*)),
this, SLOT(editorOpened(Core::IEditor*)));
}
void FakeVimPluginPrivate::aboutToShutdown()
{
theFakeVimSettings()->writeSettings(ICore::instance()->settings());
......@@ -618,6 +626,8 @@ bool FakeVimPluginPrivate::initialize()
actionManager()->actionContainer(Core::Constants::M_EDIT_ADVANCED);
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR);
connect(m_core, SIGNAL(coreAboutToClose()), this, SLOT(onCoreAboutToClose()));
// EditorManager
connect(editorManager(), SIGNAL(editorAboutToClose(Core::IEditor*)),
this, SLOT(editorAboutToClose(Core::IEditor*)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment