Commit 2de4a98c authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Fixed id syncing when and id gets removed from the QML source.

Task-number: BAUHAUS-780
Reviewed-by: kkoehne
parent b0995968
...@@ -636,6 +636,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, ...@@ -636,6 +636,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
context->enterScope(astNode); context->enterScope(astNode);
QSet<QString> modelPropertyNames = QSet<QString>::fromList(modelNode.propertyNames()); QSet<QString> modelPropertyNames = QSet<QString>::fromList(modelNode.propertyNames());
if (!modelNode.id().isEmpty())
modelPropertyNames.insert(QLatin1String("id"));
QList<UiObjectMember *> defaultPropertyItems; QList<UiObjectMember *> defaultPropertyItems;
for (UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) { for (UiObjectMemberList *iter = astInitializer->members; iter; iter = iter->next) {
...@@ -744,7 +746,10 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, ...@@ -744,7 +746,10 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
AbstractProperty modelProperty = modelNode.property(modelPropertyName); AbstractProperty modelProperty = modelNode.property(modelPropertyName);
// property deleted. // property deleted.
differenceHandler.propertyAbsentFromQml(modelProperty); if (modelPropertyName == QLatin1String("id"))
differenceHandler.idsDiffer(modelNode, QString());
else
differenceHandler.propertyAbsentFromQml(modelProperty);
} }
context->leaveScope(); context->leaveScope();
......
...@@ -5441,7 +5441,7 @@ void TestCore::testRewriterRemoveId() ...@@ -5441,7 +5441,7 @@ void TestCore::testRewriterRemoveId()
QVERIFY(view.data()); QVERIFY(view.data());
model->attachView(view.data()); model->attachView(view.data());
QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView(0, TestRewriterView::Amend));
testRewriterView->setTextModifier(&textModifier); testRewriterView->setTextModifier(&textModifier);
model->attachView(testRewriterView.data()); model->attachView(testRewriterView.data());
...@@ -5449,7 +5449,6 @@ void TestCore::testRewriterRemoveId() ...@@ -5449,7 +5449,6 @@ void TestCore::testRewriterRemoveId()
QVERIFY(rootModelNode.isValid()); QVERIFY(rootModelNode.isValid());
QCOMPARE(rootModelNode.id(), QString("rect")); QCOMPARE(rootModelNode.id(), QString("rect"));
QSKIP("Fix me!!!! Task BAUHAUS-780", SkipAll);
// //
// remove id in text // remove id in text
// //
......
...@@ -83,7 +83,9 @@ VariantProperty TestModelToTextMerger::findAddedVariantProperty(const VariantPro ...@@ -83,7 +83,9 @@ VariantProperty TestModelToTextMerger::findAddedVariantProperty(const VariantPro
return VariantProperty(); return VariantProperty();
} }
TestRewriterView::TestRewriterView(QObject *parent) : RewriterView(RewriterView::Validate, parent) TestRewriterView::TestRewriterView(QObject *parent,
DifferenceHandling differenceHandling)
: RewriterView(differenceHandling, parent)
{ {
} }
......
...@@ -53,7 +53,8 @@ class TestRewriterView : public RewriterView ...@@ -53,7 +53,8 @@ class TestRewriterView : public RewriterView
Q_OBJECT Q_OBJECT
public: public:
TestRewriterView(QObject *parent = 0); TestRewriterView(QObject *parent = 0,
DifferenceHandling differenceHandling = RewriterView::Validate);
Internal::TestModelToTextMerger *modelToTextMerger() const; Internal::TestModelToTextMerger *modelToTextMerger() const;
Internal::TextToModelMerger *textToModelMerger() const; Internal::TextToModelMerger *textToModelMerger() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment