forked from qt-creator/qt-creator
QmlProject: Fix creator becoming unresponsive if filesystem changes
Buffer update calls to the project tree. Otherwise large updates (e.g. renaming a directory) will block QtCreator for up to several minutes. Reviewed-by: ckamm
This commit is contained in:
@@ -8,7 +8,10 @@ FileFilterBaseItem::FileFilterBaseItem(QObject *parent) :
|
||||
QmlProjectContentItem(parent),
|
||||
m_recurse(RecurseDefault)
|
||||
{
|
||||
m_updateFileListTimer.setSingleShot(true);
|
||||
m_updateFileListTimer.setInterval(50);
|
||||
connect(&m_dirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(updateFileList()));
|
||||
connect(&m_updateFileListTimer, SIGNAL(timeout()), this, SLOT(updateFileListNow()));
|
||||
}
|
||||
|
||||
QString FileFilterBaseItem::directory() const
|
||||
@@ -32,7 +35,7 @@ void FileFilterBaseItem::setDefaultDirectory(const QString &dirPath)
|
||||
return;
|
||||
m_defaultDir = dirPath;
|
||||
|
||||
updateFileList();
|
||||
updateFileListNow();
|
||||
}
|
||||
|
||||
QString FileFilterBaseItem::filter() const
|
||||
@@ -155,6 +158,15 @@ QString FileFilterBaseItem::absoluteDir() const
|
||||
|
||||
void FileFilterBaseItem::updateFileList()
|
||||
{
|
||||
if (!m_updateFileListTimer.isActive())
|
||||
m_updateFileListTimer.start();
|
||||
}
|
||||
|
||||
void FileFilterBaseItem::updateFileListNow()
|
||||
{
|
||||
if (m_updateFileListTimer.isActive())
|
||||
m_updateFileListTimer.stop();
|
||||
|
||||
const QString projectDir = absoluteDir();
|
||||
if (projectDir.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QSet>
|
||||
#include <qdeclarative.h>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qmlprojectitem.h"
|
||||
#include "filesystemwatcher.h"
|
||||
@@ -49,6 +50,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void updateFileList();
|
||||
void updateFileListNow();
|
||||
|
||||
private:
|
||||
QString absolutePath(const QString &path) const;
|
||||
@@ -74,6 +76,7 @@ private:
|
||||
|
||||
QSet<QString> m_files;
|
||||
FileSystemWatcher m_dirWatcher;
|
||||
QTimer m_updateFileListTimer;
|
||||
|
||||
|
||||
friend class ProjectItem;
|
||||
|
||||
Reference in New Issue
Block a user