CppTools: Garbage collect if the last CppEditor is closed

Task-number: QTCREATORBUG-9828

Change-Id: Ie0ef9757cedb772702e49542b58d5b589506aa9e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-07-16 16:20:46 +02:00
parent bc4fa63f84
commit c84e3a27d6
3 changed files with 35 additions and 2 deletions

View File

@@ -618,21 +618,22 @@ void CppModelManager::deleteEditorSupport(TextEditor::BaseTextEditor *textEditor
return;
CppEditorSupport *editorSupport;
int numberOfOpenEditors = 0;
{ // only lock the operations on m_editorSupport
QMutexLocker locker(&m_editorSupportMutex);
editorSupport = m_editorSupport.value(textEditor, 0);
m_editorSupport.remove(textEditor);
numberOfOpenEditors = m_editorSupport.size();
}
delete editorSupport;
++numberOfClosedEditors;
if (numberOfClosedEditors == 5) {
if (numberOfOpenEditors == 0 || numberOfClosedEditors == 5) {
numberOfClosedEditors = 0;
GC();
}
}
bool CppModelManager::isCppEditor(Core::IEditor *editor) const