forked from qt-creator/qt-creator
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:
@@ -280,6 +280,9 @@ static QString _methodName(UiSourceElement *source)
|
||||
|
||||
void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const QList<QDeclarativeDebugObjectReference > &debugReferences, const Document::Ptr &doc)
|
||||
{
|
||||
if (doNotSendChanges)
|
||||
return;
|
||||
|
||||
if (!member || !parentMember)
|
||||
return;
|
||||
|
||||
@@ -311,6 +314,9 @@ void QmlJSInspector::Internal::Delta::update(UiObjectDefinition* oldObject, cons
|
||||
UiObjectDefinition* newObject, const QmlJS::Document::Ptr& newDoc,
|
||||
const QList< QDeclarativeDebugObjectReference >& debugReferences)
|
||||
{
|
||||
if (doNotSendChanges)
|
||||
return;
|
||||
|
||||
Q_ASSERT (oldObject && newObject);
|
||||
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.
|
||||
for (UiObjectMemberList *previousObjectMemberIt = Delta::objectMembers(oldObject); previousObjectMemberIt; previousObjectMemberIt = previousObjectMemberIt->next) {
|
||||
if (UiScriptBinding *previousScript = cast<UiScriptBinding *>(previousObjectMemberIt->member)) {
|
||||
@@ -562,6 +572,8 @@ void Delta::updateScriptBinding(const QDeclarativeDebugObjectReference &objectRe
|
||||
const QString &propertyName,
|
||||
const QString &scriptCode)
|
||||
{
|
||||
if (doNotSendChanges)
|
||||
return;
|
||||
QVariant expr = scriptCode;
|
||||
|
||||
const bool isLiteral = isLiteralValue(scriptBinding);
|
||||
|
||||
@@ -46,6 +46,10 @@ namespace Internal {
|
||||
class Delta
|
||||
{
|
||||
public:
|
||||
Delta() : doNotSendChanges(false) {}
|
||||
|
||||
bool doNotSendChanges;
|
||||
|
||||
struct Change {
|
||||
Change(): script(0), isLiteral(false) {}
|
||||
|
||||
@@ -54,7 +58,6 @@ public:
|
||||
QDeclarativeDebugObjectReference ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef QHash< UiObjectMember*, QList<QDeclarativeDebugObjectReference > > DebugIdMap;
|
||||
DebugIdMap operator()(const QmlJS::Document::Ptr &doc1, const QmlJS::Document::Ptr &doc2, const DebugIdMap &debugIds);
|
||||
|
||||
|
||||
@@ -75,9 +75,6 @@ public:
|
||||
CppProjectWithQmlEngines,
|
||||
QmlProjectWithCppPlugins
|
||||
};
|
||||
|
||||
QHash< QString, QList< QPair< QmlJS::AST::UiObjectMember*, int > > > m_initialTable;
|
||||
|
||||
public:
|
||||
Inspector(QObject *parent = 0);
|
||||
virtual ~Inspector();
|
||||
|
||||
@@ -98,7 +98,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
||||
}
|
||||
|
||||
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();
|
||||
m_filename = doc->fileName();
|
||||
@@ -177,7 +177,7 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
||||
|
||||
void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference &rootReference)
|
||||
{
|
||||
QmlJS::Document::Ptr doc = m_previousDoc;
|
||||
QmlJS::Document::Ptr doc = m_initialDoc;
|
||||
|
||||
if (!doc->qmlProgram())
|
||||
return;
|
||||
@@ -188,6 +188,9 @@ void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference
|
||||
doc->qmlProgram()->accept(&visitor);
|
||||
|
||||
m_debugIds = visitor.result;
|
||||
Delta delta;
|
||||
delta.doNotSendChanges = true;
|
||||
m_debugIds = delta(doc, m_previousDoc, m_debugIds);
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
||||
|
||||
@@ -55,10 +55,10 @@ private:
|
||||
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
|
||||
|
||||
private:
|
||||
QHash<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference> > m_initialTable;
|
||||
QHash<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference> > m_debugIds;
|
||||
|
||||
QmlJS::Document::Ptr m_previousDoc;
|
||||
QmlJS::Document::Ptr m_initialDoc; //the document that was loaded by the server
|
||||
QString m_filename;
|
||||
|
||||
QList<QWeakPointer<QmlJSEditor::Internal::QmlJSTextEditor> > m_editors;
|
||||
|
||||
Reference in New Issue
Block a user