forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
@@ -141,6 +141,7 @@ private slots:
|
||||
void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc);
|
||||
void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan);
|
||||
void startCppQmlTypeUpdate();
|
||||
void asyncReset();
|
||||
|
||||
private:
|
||||
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
|
||||
@@ -160,6 +161,7 @@ private:
|
||||
QFutureSynchronizer<void> m_synchronizer;
|
||||
|
||||
QTimer *m_updateCppQmlTypesTimer;
|
||||
QTimer *m_asyncResetTimer;
|
||||
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
||||
QFuture<void> m_cppQmlTypesUpdater;
|
||||
QmlJS::QrcCache m_qrcCache;
|
||||
|
||||
Reference in New Issue
Block a user