forked from qt-creator/qt-creator
QmlDesigner: Do not generate auxiliaryDataAsQML for offset -1
If a node does not have a proper offset, then the data is inconsistent. Change-Id: I1fbff3e169b225bc4ca00b1deb21982f30281f9a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -486,6 +486,8 @@ QString RewriterView::auxiliaryDataAsQML() const
|
|||||||
|
|
||||||
QString str = "Designer {\n ";
|
QString str = "Designer {\n ";
|
||||||
|
|
||||||
|
QTC_ASSERT(!m_canonicalIntModelNode.isEmpty(), return {});
|
||||||
|
|
||||||
int columnCount = 0;
|
int columnCount = 0;
|
||||||
for (const auto &node : allModelNodes()) {
|
for (const auto &node : allModelNodes()) {
|
||||||
QHash<PropertyName, QVariant> data = node.auxiliaryData();
|
QHash<PropertyName, QVariant> data = node.auxiliaryData();
|
||||||
@@ -727,8 +729,11 @@ void RewriterView::setupCanonicalHashes() const
|
|||||||
using myPair = std::pair<ModelNode,int>;
|
using myPair = std::pair<ModelNode,int>;
|
||||||
std::vector<myPair> data;
|
std::vector<myPair> data;
|
||||||
|
|
||||||
for (const ModelNode &node : allModelNodes())
|
for (const ModelNode &node : allModelNodes()) {
|
||||||
data.emplace_back(std::make_pair(node, nodeOffset(node)));
|
int offset = nodeOffset(node);
|
||||||
|
QTC_ASSERT(offset > 0, qDebug() << Q_FUNC_INFO << "no offset" << node; return);
|
||||||
|
data.emplace_back(std::make_pair(node, offset));
|
||||||
|
}
|
||||||
|
|
||||||
std::sort(data.begin(), data.end(), [](myPair a, myPair b) {
|
std::sort(data.begin(), data.end(), [](myPair a, myPair b) {
|
||||||
return a.second < b.second;
|
return a.second < b.second;
|
||||||
@@ -1066,6 +1071,8 @@ void RewriterView::restoreAuxiliaryData()
|
|||||||
|
|
||||||
setupCanonicalHashes();
|
setupCanonicalHashes();
|
||||||
|
|
||||||
|
QTC_ASSERT(!m_canonicalIntModelNode.isEmpty(), return);
|
||||||
|
|
||||||
const QString text = m_textModifier->text();
|
const QString text = m_textModifier->text();
|
||||||
|
|
||||||
int startIndex = text.indexOf(annotationsStart());
|
int startIndex = text.indexOf(annotationsStart());
|
||||||
|
Reference in New Issue
Block a user