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:
Christian Kamm
2011-12-02 14:46:23 +01:00
parent 86ba284d06
commit 7b9a42da15
4 changed files with 37 additions and 46 deletions

View File

@@ -43,30 +43,6 @@
namespace QmlJSEditor {
namespace Internal {
struct SemanticInfoUpdaterSource
{
QmlJS::Document::Ptr document;
QmlJS::Snapshot snapshot;
SemanticInfoUpdaterSource()
{ }
SemanticInfoUpdaterSource(const QmlJS::Document::Ptr &document,
const QmlJS::Snapshot &snapshot)
: document(document)
, snapshot(snapshot)
{ }
bool isValid() const
{ return document; }
void clear()
{
document.clear();
snapshot = QmlJS::Snapshot();
}
};
class SemanticInfoUpdater: public QThread
{
Q_OBJECT
@@ -76,7 +52,8 @@ public:
virtual ~SemanticInfoUpdater();
void abort();
void update(const SemanticInfoUpdaterSource &source);
void update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot);
void reupdate(const QmlJS::Snapshot &snapshot);
Q_SIGNALS:
void updated(const QmlJSEditor::SemanticInfo &semanticInfo);
@@ -85,13 +62,14 @@ protected:
virtual void run();
private:
SemanticInfo makeNewSemanticInfo(const SemanticInfoUpdaterSource &source);
SemanticInfo makeNewSemanticInfo(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot);
private:
QMutex m_mutex;
QWaitCondition m_condition;
bool m_wasCancelled;
SemanticInfoUpdaterSource m_source;
QmlJS::Document::Ptr m_sourceDocument;
QmlJS::Snapshot m_sourceSnapshot;
SemanticInfo m_lastSemanticInfo;
};