Commit feff3382 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

C++: fix crash when failing to open non-existing file.

Change-Id: Ie7bd3b36139ab7fac1186cefa7222dff7277eb53
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 2ddb726d
......@@ -562,9 +562,13 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
CPPEditorWidget::~CPPEditorWidget()
{
if (m_modelManager)
m_modelManager->deleteEditorSupport(editor());
++numberOfClosedEditors;
if (numberOfClosedEditors == 5) {
m_modelManager->GC();
if (m_modelManager)
m_modelManager->GC();
numberOfClosedEditors = 0;
}
......
......@@ -245,10 +245,6 @@ CppModelManager::CppModelManager(QObject *parent)
qRegisterMetaType<CPlusPlus::Document::Ptr>("CPlusPlus::Document::Ptr");
// Listen for editor closed events so that we can keep track of changing files
connect(Core::ICore::editorManager(), SIGNAL(editorAboutToClose(Core::IEditor*)),
this, SLOT(editorAboutToClose(Core::IEditor*)));
m_completionFallback = new InternalCompletionAssistProvider;
m_completionAssistProvider = m_completionFallback;
ExtensionSystem::PluginManager::addObject(m_completionAssistProvider);
......@@ -602,14 +598,13 @@ QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) co
}
/// \brief Removes the CppEditorSupport for the closed editor.
void CppModelManager::editorAboutToClose(Core::IEditor *editor)
void CppModelManager::deleteEditorSupport(TextEditor::BaseTextEditor *textEditor)
{
if (!isCppEditor(editor))
return;
TextEditor::BaseTextEditor *textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor);
QTC_ASSERT(textEditor, return);
if (!isCppEditor(textEditor))
return;
QMutexLocker locker(&m_editorSupportMutex);
CppEditorSupport *editorSupport = m_editorSupport.value(textEditor, 0);
m_editorSupport.remove(textEditor);
......
......@@ -87,6 +87,7 @@ public:
virtual void addEditorSupport(AbstractEditorSupport *editorSupport);
virtual void removeEditorSupport(AbstractEditorSupport *editorSupport);
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor);
virtual void deleteEditorSupport(TextEditor::BaseTextEditor *textEditor);
virtual QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
......@@ -139,7 +140,6 @@ Q_SIGNALS:
void aboutToRemoveFiles(const QStringList &files);
public Q_SLOTS:
void editorAboutToClose(Core::IEditor *editor);
virtual void updateModifiedSourceFiles();
private Q_SLOTS:
......
......@@ -215,6 +215,7 @@ public:
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor) = 0;
virtual void deleteEditorSupport(TextEditor::BaseTextEditor *textEditor) = 0;
virtual QList<int> references(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context) = 0;
......
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