Commit eb1d87b3 authored by Fawzi Mohamed's avatar Fawzi Mohamed

qmljs: coalesce resets of code model triggered by cpp files update

Use a timer to avoid resetting the model too often.

Change-Id: Iadf3ff3f03cfc91df44168243972b1e5a0ee5077
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent c264c0d2
...@@ -243,6 +243,11 @@ ModelManager::ModelManager(QObject *parent): ...@@ -243,6 +243,11 @@ ModelManager::ModelManager(QObject *parent):
m_updateCppQmlTypesTimer->setSingleShot(true); m_updateCppQmlTypesTimer->setSingleShot(true);
connect(m_updateCppQmlTypesTimer, SIGNAL(timeout()), SLOT(startCppQmlTypeUpdate())); connect(m_updateCppQmlTypesTimer, SIGNAL(timeout()), SLOT(startCppQmlTypeUpdate()));
m_asyncResetTimer = new QTimer(this);
m_asyncResetTimer->setInterval(1000);
m_asyncResetTimer->setSingleShot(true);
connect(m_asyncResetTimer, SIGNAL(timeout()), SLOT(resetCodeModel()));
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr"); qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo"); qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo"); qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo");
...@@ -1056,6 +1061,11 @@ void ModelManager::startCppQmlTypeUpdate() ...@@ -1056,6 +1061,11 @@ void ModelManager::startCppQmlTypeUpdate()
m_queuedCppDocuments.clear(); m_queuedCppDocuments.clear();
} }
void ModelManager::asyncReset()
{
m_asyncResetTimer->start();
}
void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface, void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface,
ModelManager *qmlModelManager, ModelManager *qmlModelManager,
CPlusPlus::Snapshot snapshot, CPlusPlus::Snapshot snapshot,
...@@ -1100,7 +1110,7 @@ void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface, ...@@ -1100,7 +1110,7 @@ void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface,
qmlModelManager->m_cppDataHash = newData; qmlModelManager->m_cppDataHash = newData;
if (hasNewInfo) if (hasNewInfo)
// one could get away with re-linking the cpp types... // one could get away with re-linking the cpp types...
QMetaObject::invokeMethod(qmlModelManager, "resetCodeModel"); QMetaObject::invokeMethod(qmlModelManager, "asyncReset");
} }
ModelManager::CppDataHash ModelManager::cppData() const ModelManager::CppDataHash ModelManager::cppData() const
......
...@@ -141,6 +141,7 @@ private slots: ...@@ -141,6 +141,7 @@ private slots:
void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc); void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc);
void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan); void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan);
void startCppQmlTypeUpdate(); void startCppQmlTypeUpdate();
void asyncReset();
private: private:
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType); static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
...@@ -160,6 +161,7 @@ private: ...@@ -160,6 +161,7 @@ private:
QFutureSynchronizer<void> m_synchronizer; QFutureSynchronizer<void> m_synchronizer;
QTimer *m_updateCppQmlTypesTimer; QTimer *m_updateCppQmlTypesTimer;
QTimer *m_asyncResetTimer;
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments; QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
QFuture<void> m_cppQmlTypesUpdater; QFuture<void> m_cppQmlTypesUpdater;
QmlJS::QrcCache m_qrcCache; QmlJS::QrcCache m_qrcCache;
......
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