forked from qt-creator/qt-creator
Remove Qt4ProFileNode::updateUiFilesFromBuild
The function made sure that the code model knew about changes to the ui_*.h files. This code was written before introducing Qt4UiCodeModelSupport, which does ensure that the ui*.h files on disk actually do not matter for the code model at all. Removing this code improves switching Kits performance in some cases. Change-Id: I51f9fcc9cac23013eaf89a2a8517f2bd58953263 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -1484,10 +1484,9 @@ bool Qt4ProFileNode::isParent(Qt4ProFileNode *node)
|
|||||||
|
|
||||||
void Qt4ProFileNode::buildStateChanged(ProjectExplorer::Project *project)
|
void Qt4ProFileNode::buildStateChanged(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
if (project == m_project && !ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(m_project)) {
|
if (project == m_project
|
||||||
QStringList filesToUpdate = updateUiFiles();
|
&& !ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager()->isBuilding(m_project))
|
||||||
updateCodeModelSupportFromBuild(filesToUpdate);
|
updateCodeModelSupportFromBuild();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Qt4ProFileNode::hasBuildTargets() const
|
bool Qt4ProFileNode::hasBuildTargets() const
|
||||||
@@ -1522,6 +1521,11 @@ QString Qt4ProFileNode::singleVariableValue(const Qt4Variable var) const
|
|||||||
return values.isEmpty() ? QString() : values.first();
|
return values.isEmpty() ? QString() : values.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList Qt4ProFileNode::uiFiles() const
|
||||||
|
{
|
||||||
|
return m_uiHeaderFiles;
|
||||||
|
}
|
||||||
|
|
||||||
void Qt4ProFileNode::emitProFileUpdatedRecursive()
|
void Qt4ProFileNode::emitProFileUpdatedRecursive()
|
||||||
{
|
{
|
||||||
foreach (ProjectExplorer::NodesWatcher *watcher, watchers())
|
foreach (ProjectExplorer::NodesWatcher *watcher, watchers())
|
||||||
@@ -1972,7 +1976,6 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
setParseInProgress(false);
|
setParseInProgress(false);
|
||||||
|
|
||||||
createUiCodeModelSupport();
|
createUiCodeModelSupport();
|
||||||
updateUiFiles();
|
|
||||||
|
|
||||||
m_project->destroyProFileReader(m_readerExact);
|
m_project->destroyProFileReader(m_readerExact);
|
||||||
m_project->destroyProFileReader(m_readerCumulative);
|
m_project->destroyProFileReader(m_readerCumulative);
|
||||||
@@ -2004,114 +2007,6 @@ QStringList Qt4ProFileNode::fileListForVar(QtSupport::ProFileReader *readerExact
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is triggered after a build, and updates the state ui files
|
|
||||||
// It does so by storing a modification time for each ui file we know about.
|
|
||||||
QStringList Qt4ProFileNode::updateUiFiles()
|
|
||||||
{
|
|
||||||
// qDebug()<<"Qt4ProFileNode::updateUiFiles()";
|
|
||||||
// Only those two project types can have ui files for us
|
|
||||||
if (m_projectType != ApplicationTemplate
|
|
||||||
&& m_projectType != LibraryTemplate)
|
|
||||||
return QStringList();
|
|
||||||
|
|
||||||
// Find all ui files
|
|
||||||
FindUiFileNodesVisitor uiFilesVisitor;
|
|
||||||
this->accept(&uiFilesVisitor);
|
|
||||||
const QList<ProjectExplorer::FileNode*> uiFiles = uiFilesVisitor.uiFileNodes;
|
|
||||||
|
|
||||||
// Find the UiDir, there can only ever be one
|
|
||||||
QString uiDir = buildDir();
|
|
||||||
QStringList tmp = m_varValues[UiDirVar];
|
|
||||||
if (tmp.size() != 0)
|
|
||||||
uiDir = tmp.first();
|
|
||||||
|
|
||||||
// Collect all existing generated files
|
|
||||||
QList<ProjectExplorer::FileNode*> existingFileNodes;
|
|
||||||
foreach (ProjectExplorer::FileNode *file, fileNodes()) {
|
|
||||||
if (file->isGenerated())
|
|
||||||
existingFileNodes << file;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert uiFile to uiHeaderFilePath, find all headers that correspond
|
|
||||||
// and try to find them in uiDir
|
|
||||||
QStringList newFilePaths;
|
|
||||||
foreach (ProjectExplorer::FileNode *uiFile, uiFiles) {
|
|
||||||
const QString uiHeaderFilePath
|
|
||||||
= QString::fromLatin1("%1/ui_%2.h").arg(uiDir, QFileInfo(uiFile->path()).completeBaseName());
|
|
||||||
if (QFileInfo(uiHeaderFilePath).exists())
|
|
||||||
newFilePaths << uiHeaderFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a diff between those lists
|
|
||||||
QList<ProjectExplorer::FileNode*> toRemove;
|
|
||||||
QList<ProjectExplorer::FileNode*> toAdd;
|
|
||||||
// The list of files for which we call updateSourceFile
|
|
||||||
QStringList toUpdate;
|
|
||||||
|
|
||||||
qSort(newFilePaths);
|
|
||||||
qSort(existingFileNodes.begin(), existingFileNodes.end(), sortNodesByPath);
|
|
||||||
|
|
||||||
QList<ProjectExplorer::FileNode*>::const_iterator existingNodeIter = existingFileNodes.constBegin();
|
|
||||||
QList<QString>::const_iterator newPathIter = newFilePaths.constBegin();
|
|
||||||
while (existingNodeIter != existingFileNodes.constEnd()
|
|
||||||
&& newPathIter != newFilePaths.constEnd()) {
|
|
||||||
if ((*existingNodeIter)->path() < *newPathIter) {
|
|
||||||
toRemove << *existingNodeIter;
|
|
||||||
++existingNodeIter;
|
|
||||||
} else if ((*existingNodeIter)->path() > *newPathIter) {
|
|
||||||
toAdd << new ProjectExplorer::FileNode(*newPathIter, ProjectExplorer::HeaderType, true);
|
|
||||||
++newPathIter;
|
|
||||||
} else { // *existingNodeIter->path() == *newPathIter
|
|
||||||
QString fileName = (*existingNodeIter)->path();
|
|
||||||
QMap<QString, QDateTime>::const_iterator it = m_uitimestamps.find(fileName);
|
|
||||||
QDateTime lastModified = QFileInfo(fileName).lastModified();
|
|
||||||
if (it == m_uitimestamps.constEnd() || it.value() < lastModified) {
|
|
||||||
toUpdate << fileName;
|
|
||||||
m_uitimestamps[fileName] = lastModified;
|
|
||||||
}
|
|
||||||
++existingNodeIter;
|
|
||||||
++newPathIter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (existingNodeIter != existingFileNodes.constEnd()) {
|
|
||||||
toRemove << *existingNodeIter;
|
|
||||||
++existingNodeIter;
|
|
||||||
}
|
|
||||||
while (newPathIter != newFilePaths.constEnd()) {
|
|
||||||
toAdd << new ProjectExplorer::FileNode(*newPathIter, ProjectExplorer::HeaderType, true);
|
|
||||||
++newPathIter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update project tree
|
|
||||||
if (!toRemove.isEmpty()) {
|
|
||||||
foreach (ProjectExplorer::FileNode *file, toRemove)
|
|
||||||
m_uitimestamps.remove(file->path());
|
|
||||||
removeFileNodes(toRemove, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
CPlusPlus::CppModelManagerInterface *modelManager =
|
|
||||||
CPlusPlus::CppModelManagerInterface::instance();
|
|
||||||
|
|
||||||
if (!toAdd.isEmpty()) {
|
|
||||||
foreach (ProjectExplorer::FileNode *file, toAdd) {
|
|
||||||
m_uitimestamps.insert(file->path(), QFileInfo(file->path()).lastModified());
|
|
||||||
toUpdate << file->path();
|
|
||||||
|
|
||||||
// Also adding files depending on that
|
|
||||||
// We only need to do that for files that were newly created
|
|
||||||
QString fileName = QFileInfo(file->path()).fileName();
|
|
||||||
foreach (CPlusPlus::Document::Ptr doc, modelManager->snapshot()) {
|
|
||||||
if (doc->includedFiles().contains(fileName)) {
|
|
||||||
if (!toUpdate.contains(doc->fileName()))
|
|
||||||
toUpdate << doc->fileName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addFileNodes(toAdd, this);
|
|
||||||
}
|
|
||||||
return toUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Qt4ProFileNode::uiDirPath(QtSupport::ProFileReader *reader) const
|
QString Qt4ProFileNode::uiDirPath(QtSupport::ProFileReader *reader) const
|
||||||
{
|
{
|
||||||
QString path = reader->value(QLatin1String("UI_DIR"));
|
QString path = reader->value(QLatin1String("UI_DIR"));
|
||||||
@@ -2350,16 +2245,12 @@ QString Qt4ProFileNode::buildDir(Qt4BuildConfiguration *bc) const
|
|||||||
return QDir(bc->buildDirectory()).absoluteFilePath(relativeDir);
|
return QDir(bc->buildDirectory()).absoluteFilePath(relativeDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt4ProFileNode::updateCodeModelSupportFromBuild(const QStringList &files)
|
void Qt4ProFileNode::updateCodeModelSupportFromBuild()
|
||||||
{
|
{
|
||||||
foreach (const QString &file, files) {
|
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end;
|
||||||
QMap<QString, Internal::Qt4UiCodeModelSupport *>::const_iterator it, end;
|
end = m_uiCodeModelSupport.constEnd();
|
||||||
end = m_uiCodeModelSupport.constEnd();
|
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it)
|
||||||
for (it = m_uiCodeModelSupport.constBegin(); it != end; ++it) {
|
it.value()->updateFromBuild();
|
||||||
if (it.value()->fileName() == file)
|
|
||||||
it.value()->updateFromBuild();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt4ProFileNode::updateCodeModelSupportFromEditor(const QString &uiFileName,
|
void Qt4ProFileNode::updateCodeModelSupportFromEditor(const QString &uiFileName,
|
||||||
@@ -2402,6 +2293,8 @@ void Qt4ProFileNode::createUiCodeModelSupport()
|
|||||||
oldCodeModelSupport = m_uiCodeModelSupport;
|
oldCodeModelSupport = m_uiCodeModelSupport;
|
||||||
m_uiCodeModelSupport.clear();
|
m_uiCodeModelSupport.clear();
|
||||||
|
|
||||||
|
m_uiHeaderFiles.clear();
|
||||||
|
|
||||||
// Only those two project types can have ui files for us
|
// Only those two project types can have ui files for us
|
||||||
if (m_projectType == ApplicationTemplate || m_projectType == LibraryTemplate) {
|
if (m_projectType == ApplicationTemplate || m_projectType == LibraryTemplate) {
|
||||||
// Find all ui files
|
// Find all ui files
|
||||||
@@ -2413,6 +2306,7 @@ void Qt4ProFileNode::createUiCodeModelSupport()
|
|||||||
const QString uiDir = uiDirectory();
|
const QString uiDir = uiDirectory();
|
||||||
foreach (const ProjectExplorer::FileNode *uiFile, uiFiles) {
|
foreach (const ProjectExplorer::FileNode *uiFile, uiFiles) {
|
||||||
const QString uiHeaderFilePath = uiHeaderFile(uiDir, uiFile->path());
|
const QString uiHeaderFilePath = uiHeaderFile(uiDir, uiFile->path());
|
||||||
|
m_uiHeaderFiles << uiHeaderFilePath;
|
||||||
// qDebug()<<"code model support for "<<uiFile->path()<<" "<<uiHeaderFilePath;
|
// qDebug()<<"code model support for "<<uiFile->path()<<" "<<uiHeaderFilePath;
|
||||||
QMap<QString, Internal::Qt4UiCodeModelSupport *>::iterator it = oldCodeModelSupport.find(uiFile->path());
|
QMap<QString, Internal::Qt4UiCodeModelSupport *>::iterator it = oldCodeModelSupport.find(uiFile->path());
|
||||||
if (it != oldCodeModelSupport.end()) {
|
if (it != oldCodeModelSupport.end()) {
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ public:
|
|||||||
return !m_subProjectsNotToDeploy.contains(filePath);
|
return !m_subProjectsNotToDeploy.contains(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateCodeModelSupportFromBuild(const QStringList &files);
|
void updateCodeModelSupportFromBuild();
|
||||||
void updateCodeModelSupportFromEditor(const QString &uiFileName, const QString &contents);
|
void updateCodeModelSupportFromEditor(const QString &uiFileName, const QString &contents);
|
||||||
|
|
||||||
QString sourceDir() const;
|
QString sourceDir() const;
|
||||||
@@ -375,6 +375,7 @@ public:
|
|||||||
|
|
||||||
QString uiDirectory() const;
|
QString uiDirectory() const;
|
||||||
static QString uiHeaderFile(const QString &uiDir, const QString &formFile);
|
static QString uiHeaderFile(const QString &uiDir, const QString &formFile);
|
||||||
|
QStringList uiFiles() const;
|
||||||
|
|
||||||
const Qt4ProFileNode *findProFileFor(const QString &string) const;
|
const Qt4ProFileNode *findProFileFor(const QString &string) const;
|
||||||
TargetInformation targetInformation(const QString &fileName) const;
|
TargetInformation targetInformation(const QString &fileName) const;
|
||||||
@@ -421,7 +422,6 @@ private:
|
|||||||
typedef QHash<Qt4Variable, QStringList> Qt4VariablesHash;
|
typedef QHash<Qt4Variable, QStringList> Qt4VariablesHash;
|
||||||
|
|
||||||
void createUiCodeModelSupport();
|
void createUiCodeModelSupport();
|
||||||
QStringList updateUiFiles();
|
|
||||||
|
|
||||||
QStringList fileListForVar(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative,
|
QStringList fileListForVar(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative,
|
||||||
const QString &varName, const QString &projectDir, FileType type) const;
|
const QString &varName, const QString &projectDir, FileType type) const;
|
||||||
@@ -448,6 +448,8 @@ private:
|
|||||||
bool m_validParse;
|
bool m_validParse;
|
||||||
bool m_parseInProgress;
|
bool m_parseInProgress;
|
||||||
|
|
||||||
|
QStringList m_uiHeaderFiles;
|
||||||
|
|
||||||
// Async stuff
|
// Async stuff
|
||||||
QFutureWatcher<EvalResult> m_parseFutureWatcher;
|
QFutureWatcher<EvalResult> m_parseFutureWatcher;
|
||||||
QtSupport::ProFileReader *m_readerExact;
|
QtSupport::ProFileReader *m_readerExact;
|
||||||
|
|||||||
@@ -557,6 +557,7 @@ void Qt4Project::updateCppCodeModel()
|
|||||||
|
|
||||||
part->sourceFiles = pro->variableValue(CppSourceVar);
|
part->sourceFiles = pro->variableValue(CppSourceVar);
|
||||||
part->sourceFiles += pro->variableValue(CppHeaderVar);
|
part->sourceFiles += pro->variableValue(CppHeaderVar);
|
||||||
|
part->sourceFiles += pro->uiFiles();
|
||||||
part->sourceFiles.prepend(QLatin1String("<configuration>"));
|
part->sourceFiles.prepend(QLatin1String("<configuration>"));
|
||||||
pinfo.appendProjectPart(part);
|
pinfo.appendProjectPart(part);
|
||||||
|
|
||||||
@@ -789,6 +790,7 @@ void Qt4Project::decrementPendingEvaluateFutures()
|
|||||||
// We are done!
|
// We are done!
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug()<<" reporting finished";
|
qDebug()<<" reporting finished";
|
||||||
|
|
||||||
m_asyncUpdateFutureInterface->reportFinished();
|
m_asyncUpdateFutureInterface->reportFinished();
|
||||||
delete m_asyncUpdateFutureInterface;
|
delete m_asyncUpdateFutureInterface;
|
||||||
m_asyncUpdateFutureInterface = 0;
|
m_asyncUpdateFutureInterface = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user