forked from qt-creator/qt-creator
QmlJS: Fix semantic info update triggering updates.
When a part of the semantic info update (such as a Link) triggers QmlTextEditorWidget::updateSemanticInfo (for instance by requesting QML plugin dumps) that update request was ignored because the *old* semanticInfo revision was compared to the editor revision. Instead, compare the *future* semantic info revision to check whether an update would be accepted. Also, instead of using the same snapshot, get a new one from the model manager. Otherwise updates to libraryInfos won't be considered. Change-Id: I0df6197bebce580129292aab5ca8cf24512a0fe7 Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
@@ -59,10 +59,19 @@ void SemanticInfoUpdater::abort()
|
||||
m_condition.wakeOne();
|
||||
}
|
||||
|
||||
void SemanticInfoUpdater::update(const SemanticInfoUpdaterSource &source)
|
||||
void SemanticInfoUpdater::update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
m_source = source;
|
||||
m_sourceDocument = doc;
|
||||
m_sourceSnapshot = snapshot;
|
||||
m_condition.wakeOne();
|
||||
}
|
||||
|
||||
void SemanticInfoUpdater::reupdate(const QmlJS::Snapshot &snapshot)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
m_sourceDocument = m_lastSemanticInfo.document;
|
||||
m_sourceSnapshot = snapshot;
|
||||
m_condition.wakeOne();
|
||||
}
|
||||
|
||||
@@ -73,22 +82,24 @@ void SemanticInfoUpdater::run()
|
||||
forever {
|
||||
m_mutex.lock();
|
||||
|
||||
while (! (m_wasCancelled || m_source.isValid()))
|
||||
while (! (m_wasCancelled || m_sourceDocument))
|
||||
m_condition.wait(&m_mutex);
|
||||
|
||||
const bool done = m_wasCancelled;
|
||||
const SemanticInfoUpdaterSource source = m_source;
|
||||
m_source.clear();
|
||||
QmlJS::Document::Ptr doc = m_sourceDocument;
|
||||
QmlJS::Snapshot snapshot = m_sourceSnapshot;
|
||||
m_sourceDocument.clear();
|
||||
m_sourceSnapshot = QmlJS::Snapshot();
|
||||
|
||||
m_mutex.unlock();
|
||||
|
||||
if (done)
|
||||
break;
|
||||
|
||||
const SemanticInfo info = makeNewSemanticInfo(source);
|
||||
const SemanticInfo info = makeNewSemanticInfo(doc, snapshot);
|
||||
|
||||
m_mutex.lock();
|
||||
const bool cancelledOrNewData = m_wasCancelled || m_source.isValid();
|
||||
const bool cancelledOrNewData = m_wasCancelled || m_sourceDocument;
|
||||
m_mutex.unlock();
|
||||
|
||||
if (! cancelledOrNewData) {
|
||||
@@ -98,13 +109,13 @@ void SemanticInfoUpdater::run()
|
||||
}
|
||||
}
|
||||
|
||||
SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const SemanticInfoUpdaterSource &source)
|
||||
SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot)
|
||||
{
|
||||
using namespace QmlJS;
|
||||
|
||||
SemanticInfo semanticInfo;
|
||||
const Document::Ptr &doc = semanticInfo.document = source.document;
|
||||
semanticInfo.snapshot = source.snapshot;
|
||||
semanticInfo.document = doc;
|
||||
semanticInfo.snapshot = snapshot;
|
||||
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user