diff options
author | Alexander Drozdov <adrozdoff@gmail.com> | 2016-12-04 03:36:12 +1000 |
---|---|---|
committer | Alexander Drozdov <adrozdoff@gmail.com> | 2016-12-13 21:16:56 +0000 |
commit | dfaf01614d976e228d97daf979745bed89b7f91a (patch) | |
tree | c51752bb6d253c2db6c81d685954ee0471aacf74 /src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | |
parent | 357cefe67c44b21139457f742cf11f3e07dc4e1d (diff) |
CMake: make project file system tree scanner persistent
Project source tree is a same for all build configurations so it is
a good idea to keep it persistent between CMake runs, configurations
switches and so on. It safes a lot of time for big projects.
Move more operations to the scanner thread:
- Nodes filtering: skip .user files on top level of the project, skip
well-known extensions and octet-streams: In most cases these are not
required to be shown in the project tree.
- Nodes sorting
Fix small memory leak: we have .user in the scanner result. After this
node filtered out, but is not feed (old code at the
BuildDirManager::generateProjectTree()). Now .user file skips during scan
without memory allocation at all.
Allow user manually rescan project tree by call Build -> Rescan project
tree. It runs CMake and Tree Scanner together: in most cases only CMake
run requires but time to time (VCS update) full rescan also required.
Change-Id: I4a6e6c897202da557509291c79932dd7751860e5
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 41f811736af..145bbb5d6a3 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -56,7 +56,8 @@ using namespace CMakeProjectManager::Internal; CMakeManager::CMakeManager() : m_runCMakeAction(new QAction(QIcon(), tr("Run CMake"), this)), m_clearCMakeCacheAction(new QAction(QIcon(), tr("Clear CMake Configuration"), this)), - m_runCMakeActionContextMenu(new QAction(QIcon(), tr("Run CMake"), this)) + m_runCMakeActionContextMenu(new QAction(QIcon(), tr("Run CMake"), this)), + m_rescanProjectAction(new QAction(QIcon(), tr("Rescan project"), this)) { Core::ActionContainer *mbuild = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); @@ -93,6 +94,14 @@ CMakeManager::CMakeManager() : runCMake(ProjectTree::currentProject()); }); + command = Core::ActionManager::registerAction(m_rescanProjectAction, + Constants::RESCANPROJECT, globalContext); + command->setAttribute(Core::Command::CA_Hide); + mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_DEPLOY); + connect(m_rescanProjectAction, &QAction::triggered, [this]() { + rescanProject(ProjectTree::currentProject()); + }); + connect(SessionManager::instance(), &SessionManager::startupProjectChanged, this, &CMakeManager::updateCmakeActions); connect(BuildManager::instance(), &BuildManager::buildStateChanged, @@ -107,6 +116,7 @@ void CMakeManager::updateCmakeActions() const bool visible = project && !BuildManager::isBuilding(project); m_runCMakeAction->setVisible(visible); m_clearCMakeCacheAction->setVisible(visible); + m_rescanProjectAction->setVisible(visible); } void CMakeManager::clearCMakeCache(Project *project) @@ -134,6 +144,18 @@ void CMakeManager::runCMake(Project *project) cmakeProject->runCMake(); } +void CMakeManager::rescanProject(Project *project) +{ + if (!project) + return; + CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(project); + if (!cmakeProject || !cmakeProject->activeTarget() || !cmakeProject->activeTarget()->activeBuildConfiguration()) + return; + + cmakeProject->scanProjectTree(); + cmakeProject->runCMake(); // by my experience: every rescan run requires cmake run too +} + Project *CMakeManager::openProject(const QString &fileName, QString *errorString) { Utils::FileName file = Utils::FileName::fromString(fileName); |