QmlJS: Fix infinite loop when scanning for exported C++ types.

Setting extra diagnostics would call updateDocument which would in turn
trigger another scan.

Change-Id: I3810a380cdf716a12767d94ff82dc30f8ae3954d
Reviewed-on: http://codereview.qt.nokia.com/3917
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2011-08-31 09:58:40 +02:00
parent 7bc8dd18a3
commit 9f7a2194f7
5 changed files with 44 additions and 7 deletions

View File

@@ -694,6 +694,8 @@ CppModelManager::CppModelManager(QObject *parent)
// thread connections
connect(this, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr)));
connect(this, SIGNAL(extraDiagnosticsUpdated(QString)),
this, SLOT(onExtraDiagnosticsUpdated(QString)));
// Listen for editor closed and opened events so that we can keep track of changing files
connect(m_core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
@@ -968,6 +970,22 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
if (outdated)
return;
updateEditor(doc);
}
void CppModelManager::onExtraDiagnosticsUpdated(const QString &fileName)
{
protectSnapshot.lock();
Document::Ptr doc = m_snapshot.document(fileName);
protectSnapshot.unlock();
if (doc)
updateEditor(doc);
}
void CppModelManager::updateEditor(Document::Ptr doc)
{
const QString fileName = doc->fileName();
QList<Core::IEditor *> openedEditors = m_core->editorManager()->openedEditors();
foreach (Core::IEditor *editor, openedEditors) {
if (editor->file()->fileName() == fileName) {
@@ -1297,15 +1315,11 @@ void CppModelManager::setExtraDiagnostics(const QString &fileName, int kind,
{
{
QMutexLocker locker(&protectExtraDiagnostics);
if (m_extraDiagnostics[fileName][kind] == diagnostics)
return;
m_extraDiagnostics[fileName].insert(kind, diagnostics);
}
Document::Ptr doc;
{
QMutexLocker locker(&protectSnapshot);
doc = m_snapshot.document(fileName);
}
if (doc)
emit documentUpdated(doc);
emit extraDiagnosticsUpdated(fileName);
}
QList<Document::DiagnosticMessage> CppModelManager::extraDiagnostics(const QString &fileName, int kind) const