QmlJsDelta: When coputing the debug ids, we need to do it on the original document.

Else, the line numbers does not match anymore.
This commit is contained in:
Olivier Goffart
2010-07-16 16:37:40 +02:00
parent 4b504323ec
commit c1d681811a
5 changed files with 22 additions and 7 deletions

View File

@@ -280,6 +280,9 @@ static QString _methodName(UiSourceElement *source)
void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const QList<QDeclarativeDebugObjectReference > &debugReferences, const Document::Ptr &doc) void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const QList<QDeclarativeDebugObjectReference > &debugReferences, const Document::Ptr &doc)
{ {
if (doNotSendChanges)
return;
if (!member || !parentMember) if (!member || !parentMember)
return; return;
@@ -311,6 +314,9 @@ void QmlJSInspector::Internal::Delta::update(UiObjectDefinition* oldObject, cons
UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc, UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc,
const QList< QDeclarativeDebugObjectReference >& debugReferences) const QList< QDeclarativeDebugObjectReference >& debugReferences)
{ {
if (doNotSendChanges)
return;
Q_ASSERT (oldObject && newObject); Q_ASSERT (oldObject && newObject);
QSet<QString> presentBinding; QSet<QString> presentBinding;
@@ -372,6 +378,10 @@ void QmlJSInspector::Internal::Delta::update(UiObjectDefinition* oldObject, cons
} }
} }
if (doNotSendChanges)
return;
//reset property that are not present in the new object. //reset property that are not present in the new object.
for (UiObjectMemberList *previousObjectMemberIt = Delta::objectMembers(oldObject); previousObjectMemberIt; previousObjectMemberIt = previousObjectMemberIt->next) { for (UiObjectMemberList *previousObjectMemberIt = Delta::objectMembers(oldObject); previousObjectMemberIt; previousObjectMemberIt = previousObjectMemberIt->next) {
if (UiScriptBinding *previousScript = cast<UiScriptBinding *>(previousObjectMemberIt->member)) { if (UiScriptBinding *previousScript = cast<UiScriptBinding *>(previousObjectMemberIt->member)) {
@@ -562,6 +572,8 @@ void Delta::updateScriptBinding(const QDeclarativeDebugObjectReference &objectRe
const QString &propertyName, const QString &propertyName,
const QString &scriptCode) const QString &scriptCode)
{ {
if (doNotSendChanges)
return;
QVariant expr = scriptCode; QVariant expr = scriptCode;
const bool isLiteral = isLiteralValue(scriptBinding); const bool isLiteral = isLiteralValue(scriptBinding);

View File

@@ -46,6 +46,10 @@ namespace Internal {
class Delta class Delta
{ {
public: public:
Delta() : doNotSendChanges(false) {}
bool doNotSendChanges;
struct Change { struct Change {
Change(): script(0), isLiteral(false) {} Change(): script(0), isLiteral(false) {}
@@ -54,7 +58,6 @@ public:
QDeclarativeDebugObjectReference ref; QDeclarativeDebugObjectReference ref;
}; };
public:
typedef QHash< UiObjectMember*, QList<QDeclarativeDebugObjectReference > > DebugIdMap; typedef QHash< UiObjectMember*, QList<QDeclarativeDebugObjectReference > > DebugIdMap;
DebugIdMap operator()(const QmlJS::Document::Ptr &doc1, const QmlJS::Document::Ptr &doc2, const DebugIdMap &debugIds); DebugIdMap operator()(const QmlJS::Document::Ptr &doc1, const QmlJS::Document::Ptr &doc2, const DebugIdMap &debugIds);

View File

@@ -75,9 +75,6 @@ public:
CppProjectWithQmlEngines, CppProjectWithQmlEngines,
QmlProjectWithCppPlugins QmlProjectWithCppPlugins
}; };
QHash< QString, QList< QPair< QmlJS::AST::UiObjectMember*, int > > > m_initialTable;
public: public:
Inspector(QObject *parent = 0); Inspector(QObject *parent = 0);
virtual ~Inspector(); virtual ~Inspector();

View File

@@ -98,7 +98,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
} }
QmlJSLiveTextPreview::QmlJSLiveTextPreview(QmlJS::Document::Ptr doc, QObject *parent) : QmlJSLiveTextPreview::QmlJSLiveTextPreview(QmlJS::Document::Ptr doc, QObject *parent) :
QObject(parent), m_previousDoc(doc) QObject(parent), m_previousDoc(doc), m_initialDoc(doc)
{ {
ClientProxy *clientProxy = ClientProxy::instance(); ClientProxy *clientProxy = ClientProxy::instance();
m_filename = doc->fileName(); m_filename = doc->fileName();
@@ -177,7 +177,7 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference &rootReference) void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference &rootReference)
{ {
QmlJS::Document::Ptr doc = m_previousDoc; QmlJS::Document::Ptr doc = m_initialDoc;
if (!doc->qmlProgram()) if (!doc->qmlProgram())
return; return;
@@ -188,6 +188,9 @@ void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference
doc->qmlProgram()->accept(&visitor); doc->qmlProgram()->accept(&visitor);
m_debugIds = visitor.result; m_debugIds = visitor.result;
Delta delta;
delta.doNotSendChanges = true;
m_debugIds = delta(doc, m_previousDoc, m_debugIds);
} }
void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc) void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)

View File

@@ -55,10 +55,10 @@ private:
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding); QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
private: private:
QHash<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference> > m_initialTable;
QHash<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference> > m_debugIds; QHash<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference> > m_debugIds;
QmlJS::Document::Ptr m_previousDoc; QmlJS::Document::Ptr m_previousDoc;
QmlJS::Document::Ptr m_initialDoc; //the document that was loaded by the server
QString m_filename; QString m_filename;
QList<QWeakPointer<QmlJSEditor::Internal::QmlJSTextEditor> > m_editors; QList<QWeakPointer<QmlJSEditor::Internal::QmlJSTextEditor> > m_editors;