Commit 5143e798 authored by Alex Neundorf's avatar Alex Neundorf

- only reload the project file if it has actually changed, instead of whenever

the directory containing it was modified

E.g. a "make install" of cmake itself caused kate to be busy at 100% CPU
for over a minute, since it was reloading the project once for every file
installed by "make install" (which writes a install_manifest.txt file line
by line).

Alex
parent bb4191fc
......@@ -35,6 +35,7 @@ KateProject::KateProject ()
: QObject ()
, m_worker (new KateProjectWorker (this))
, m_thread (m_worker)
, m_fileLastModified()
, m_notesDocument (0)
, m_documentsParent (0)
{
......@@ -96,10 +97,12 @@ bool KateProject::reload (bool force)
/**
* open the file for reading, bail out on error!
*/
m_fileLastModified = QDateTime();
QFile file (m_fileName);
if (!file.open (QFile::ReadOnly))
return false;
m_fileLastModified = QFileInfo(m_fileName).lastModified();
/**
* parse the whole file, bail out again on error!
*/
......
......@@ -21,6 +21,7 @@
#ifndef KATE_PROJECT_H
#define KATE_PROJECT_H
#include <QDateTime>
#include <QThread>
#include <QMap>
#include <QSharedPointer>
......@@ -135,6 +136,13 @@ class KateProject : public QObject
return m_baseDir;
}
/**
* Return the time when the project file has been modified last.
* @return QFileInfo::lastModified()
*/
QDateTime fileLastModified() const { return m_fileLastModified; }
/**
* Accessor to project map containing the whole project info.
* @return project info
......@@ -279,6 +287,8 @@ class KateProject : public QObject
*/
KateProjectWorkerThread m_thread;
QDateTime m_fileLastModified;
/**
* project file name
*/
......
......@@ -253,7 +253,10 @@ void KateProjectPlugin::slotDirectoryChanged (const QString &path)
QString fileName = path + QString("/.kateproject");
foreach (KateProject *project, m_projects) {
if (project->fileName() == fileName) {
project->reload();
QDateTime lastModified = QFileInfo(fileName).lastModified();
if (project->fileLastModified().isNull() || (lastModified > project->fileLastModified())) {
project->reload();
}
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment