forked from qt-creator/qt-creator
C++: fix crash when failing to open non-existing file.
Change-Id: Ie7bd3b36139ab7fac1186cefa7222dff7277eb53 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
2ddb726dd5
commit
feff33827c
@@ -562,8 +562,12 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
|
||||
|
||||
CPPEditorWidget::~CPPEditorWidget()
|
||||
{
|
||||
if (m_modelManager)
|
||||
m_modelManager->deleteEditorSupport(editor());
|
||||
|
||||
++numberOfClosedEditors;
|
||||
if (numberOfClosedEditors == 5) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user