forked from qt-creator/qt-creator
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:
@@ -32,6 +32,7 @@
|
||||
#include "cpppreprocessor.h"
|
||||
#include "modelmanagertesthelper.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
@@ -413,3 +414,33 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
||||
sm->removeProject(project);
|
||||
ModelManagerTestHelper::verifyClean();
|
||||
}
|
||||
|
||||
/// QTCREATORBUG-9828: Locator shows symbols of closed files
|
||||
/// Check: The garbage collector should be run if the last CppEditor is closed.
|
||||
void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
|
||||
{
|
||||
TestDataDirectory testDataDirectory(QLatin1String("testdata_guiproject1"));
|
||||
const QString file = testDataDirectory.file(QLatin1String("main.cpp"));
|
||||
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
|
||||
// Open a file in the editor
|
||||
QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
|
||||
Core::IEditor *editor = em->openEditor(file);
|
||||
QVERIFY(editor);
|
||||
QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1);
|
||||
QVERIFY(mm->isCppEditor(editor));
|
||||
QVERIFY(mm->workingCopy().contains(file));
|
||||
|
||||
// Check: File is in the snapshot
|
||||
QVERIFY(mm->snapshot().contains(file));
|
||||
|
||||
// Close file/editor
|
||||
const QList<Core::IEditor*> editorsToClose = QList<Core::IEditor*>() << editor;
|
||||
em->closeEditors(editorsToClose, /*askAboutModifiedEditors=*/ false);
|
||||
|
||||
// Check: File is removed from the snapshpt
|
||||
QVERIFY(!mm->workingCopy().contains(file));
|
||||
QVERIFY(!mm->snapshot().contains(file));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user