forked from qt-creator/qt-creator
Allow blocking auto files refresh
While importing assets, qml files are generated under the import path and this triggers files update every time a file is added. This results into high CPU usage. Task-number: QDS-1675 Change-Id: Ia0775ef78bbffedfaf2c140365ee31718e7ee3a4 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
40899c7209
commit
07cbc49d33
@@ -57,11 +57,16 @@
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextCodec>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QmlProjectManager::Internal;
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(infoLogger, "QmlProjectManager.QmlBuildSystem", QtInfoMsg)
|
||||
}
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
@@ -276,6 +281,10 @@ QStringList QmlBuildSystem::makeAbsolute(const Utils::FilePath &path, const QStr
|
||||
|
||||
void QmlBuildSystem::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
|
||||
{
|
||||
if (m_blockFilesUpdate) {
|
||||
qCDebug(infoLogger) << "Auto files refresh blocked.";
|
||||
return;
|
||||
}
|
||||
refresh(Files);
|
||||
if (!removed.isEmpty()) {
|
||||
if (auto modelManager = QmlJS::ModelManagerInterface::instance())
|
||||
|
@@ -104,6 +104,27 @@ public:
|
||||
|
||||
QPointer<QmlProjectItem> m_projectItem;
|
||||
Utils::FilePath m_canonicalProjectDir;
|
||||
|
||||
private:
|
||||
bool m_blockFilesUpdate = false;
|
||||
friend class FilesUpdateBlocker;
|
||||
};
|
||||
|
||||
class FilesUpdateBlocker {
|
||||
public:
|
||||
FilesUpdateBlocker(QmlBuildSystem* bs): m_bs(bs) {
|
||||
if (m_bs)
|
||||
m_bs->m_blockFilesUpdate = true;
|
||||
}
|
||||
|
||||
~FilesUpdateBlocker() {
|
||||
if (m_bs) {
|
||||
m_bs->m_blockFilesUpdate = false;
|
||||
m_bs->refresh(QmlBuildSystem::Everything);
|
||||
}
|
||||
}
|
||||
private:
|
||||
QPointer<QmlBuildSystem> m_bs;
|
||||
};
|
||||
|
||||
class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
|
||||
|
Reference in New Issue
Block a user