forked from qt-creator/qt-creator
QmlJS: Simplify document and library updating.
It is now guaranteed that the ModelManager's snapshot will be updated before the documentChanged/libraryInfoChanged signals are emitted. Whether the updated document/library is already in the snapshot or not was undefined before. Task-number: QTCREATORBUG-2640 Reviewed-by: Roberto Raggi
This commit is contained in:
@@ -69,11 +69,6 @@ ModelManager::ModelManager(QObject *parent):
|
|||||||
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
|
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
|
||||||
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
|
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
|
||||||
|
|
||||||
connect(this, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
|
||||||
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
|
||||||
connect(this, SIGNAL(libraryInfoUpdated(QString,QmlJS::LibraryInfo)),
|
|
||||||
this, SLOT(onLibraryInfoUpdated(QString,QmlJS::LibraryInfo)));
|
|
||||||
|
|
||||||
loadQmlTypeDescriptions();
|
loadQmlTypeDescriptions();
|
||||||
|
|
||||||
m_defaultImportPaths << environmentImportPaths();
|
m_defaultImportPaths << environmentImportPaths();
|
||||||
@@ -215,24 +210,22 @@ void ModelManager::updateProjectInfo(const ProjectInfo &pinfo)
|
|||||||
void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc)
|
void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc)
|
||||||
{ emit documentChangedOnDisk(doc); }
|
{ emit documentChangedOnDisk(doc); }
|
||||||
|
|
||||||
void ModelManager::emitDocumentUpdated(Document::Ptr doc)
|
void ModelManager::updateDocument(Document::Ptr doc)
|
||||||
{ emit documentUpdated(doc); }
|
|
||||||
|
|
||||||
void ModelManager::onDocumentUpdated(Document::Ptr doc)
|
|
||||||
{
|
{
|
||||||
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
_snapshot.insert(doc);
|
_snapshot.insert(doc);
|
||||||
|
}
|
||||||
|
emit documentUpdated(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelManager::emitLibraryInfoUpdated(const QString &path, const LibraryInfo &info)
|
void ModelManager::updateLibraryInfo(const QString &path, const LibraryInfo &info)
|
||||||
{ emit libraryInfoUpdated(path, info); }
|
|
||||||
|
|
||||||
void ModelManager::onLibraryInfoUpdated(const QString &path, const LibraryInfo &info)
|
|
||||||
{
|
{
|
||||||
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
_snapshot.insertLibraryInfo(path, info);
|
_snapshot.insertLibraryInfo(path, info);
|
||||||
|
}
|
||||||
|
emit libraryInfoUpdated(path, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList qmlFilesInDirectory(const QString &path)
|
static QStringList qmlFilesInDirectory(const QString &path)
|
||||||
@@ -318,7 +311,7 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
|
|||||||
qmldirParser.setSource(qmldirData);
|
qmldirParser.setSource(qmldirData);
|
||||||
qmldirParser.parse();
|
qmldirParser.parse();
|
||||||
|
|
||||||
modelManager->emitLibraryInfoUpdated(QFileInfo(qmldirFile).absolutePath(),
|
modelManager->updateLibraryInfo(QFileInfo(qmldirFile).absolutePath(),
|
||||||
LibraryInfo(qmldirParser));
|
LibraryInfo(qmldirParser));
|
||||||
|
|
||||||
// scan the qml files in the library
|
// scan the qml files in the library
|
||||||
@@ -405,7 +398,7 @@ void ModelManager::parse(QFutureInterface<void> &future,
|
|||||||
files.append(file);
|
files.append(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelManager->emitDocumentUpdated(doc);
|
modelManager->updateDocument(doc);
|
||||||
if (emitDocChangedOnDisk)
|
if (emitDocChangedOnDisk)
|
||||||
modelManager->emitDocumentChangedOnDisk(doc);
|
modelManager->emitDocumentChangedOnDisk(doc);
|
||||||
}
|
}
|
||||||
@@ -554,7 +547,7 @@ void ModelManager::qmlPluginTypeDumpDone(int exitCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!libraryPath.isEmpty())
|
if (!libraryPath.isEmpty())
|
||||||
emitLibraryInfoUpdated(libraryPath, libraryInfo);
|
updateLibraryInfo(libraryPath, libraryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
|
void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
|
||||||
@@ -572,6 +565,6 @@ void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
|
|||||||
if (!libraryPath.isEmpty()) {
|
if (!libraryPath.isEmpty()) {
|
||||||
LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
|
LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
|
||||||
libraryInfo.setDumped(true);
|
libraryInfo.setDumped(true);
|
||||||
emitLibraryInfoUpdated(libraryPath, libraryInfo);
|
updateLibraryInfo(libraryPath, libraryInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ public:
|
|||||||
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
||||||
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
||||||
|
|
||||||
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
|
void updateDocument(QmlJS::Document::Ptr doc);
|
||||||
void emitLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
void updateLibraryInfo(const QString &path, const QmlJS::LibraryInfo &info);
|
||||||
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
|
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
virtual QStringList importPaths() const;
|
virtual QStringList importPaths() const;
|
||||||
@@ -78,9 +78,6 @@ Q_SIGNALS:
|
|||||||
void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
// this should be executed in the GUI thread.
|
|
||||||
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
|
||||||
void onLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
|
||||||
void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri);
|
void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri);
|
||||||
void qmlPluginTypeDumpDone(int exitCode);
|
void qmlPluginTypeDumpDone(int exitCode);
|
||||||
void qmlPluginTypeDumpError(QProcess::ProcessError error);
|
void qmlPluginTypeDumpError(QProcess::ProcessError error);
|
||||||
|
|||||||
Reference in New Issue
Block a user