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: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Fawzi Mohamed
2013-06-28 18:05:00 +02:00
parent c264c0d213
commit eb1d87b30f
2 changed files with 13 additions and 1 deletions

View File

@@ -243,6 +243,11 @@ ModelManager::ModelManager(QObject *parent):
m_updateCppQmlTypesTimer->setSingleShot(true);
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::LibraryInfo>("QmlJS::LibraryInfo");
qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo");
@@ -1056,6 +1061,11 @@ void ModelManager::startCppQmlTypeUpdate()
m_queuedCppDocuments.clear();
}
void ModelManager::asyncReset()
{
m_asyncResetTimer->start();
}
void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface,
ModelManager *qmlModelManager,
CPlusPlus::Snapshot snapshot,
@@ -1100,7 +1110,7 @@ void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface,
qmlModelManager->m_cppDataHash = newData;
if (hasNewInfo)
// one could get away with re-linking the cpp types...
QMetaObject::invokeMethod(qmlModelManager, "resetCodeModel");
QMetaObject::invokeMethod(qmlModelManager, "asyncReset");
}
ModelManager::CppDataHash ModelManager::cppData() const