From 3eae45a5d6b87a3d74f2240c5f172dc8be4a2270 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 16 May 2023 10:38:31 +0000 Subject: qdoc: Store read-only attribute to index for C++ properties The .index files were missing an attribute for C++ properties that are read-only. For a PropertyNode, if setWritable() was not explicitly called, the read-only status was based on whether the property's access functions included a getter method. When reading nodes from an index, these access functions are not restored when constructing a PropertyNode as that information is not needed anymore. A side-effect of this was that all C++ property nodes read from index were considered read-only. QDoc also supports resolving the read-only status for a QML property based on the associated C++ property of a class that the parent QML type instantiates. If this instantiated class was read from index, that meant that the read-only status was resolved incorrectly. To fix, add writable="false" attribute for all read-only C++ properties written to index, and explicitly call setWritable() when reading them back in. Pick-to: 6.5 Fixes: QTBUG-113015 Change-Id: Iaf8276a892d9a764fed9a67ebd005481c16bba17 Reviewed-by: Paul Wicking --- src/qdoc/qdoc/qdocindexfiles.cpp | 5 +++++ .../qdoc/generatedoutput/expected_output/properties/testcpp.index | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/qdoc/qdoc/qdocindexfiles.cpp b/src/qdoc/qdoc/qdocindexfiles.cpp index e9bdda715..a5d49e4dc 100644 --- a/src/qdoc/qdoc/qdocindexfiles.cpp +++ b/src/qdoc/qdoc/qdocindexfiles.cpp @@ -402,6 +402,8 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current, if (attributes.value(QLatin1String("bindable")) == QLatin1String("true")) propNode->setPropertyType(PropertyNode::PropertyType::BindableProperty); + propNode->setWritable(attributes.value(QLatin1String("writable")) != QLatin1String("false")); + if (!indexUrl.isEmpty()) location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html"); else if (!indexUrl.isNull()) @@ -1015,6 +1017,9 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter &writer, Node *node, if (propertyNode->propertyType() == PropertyNode::PropertyType::BindableProperty) writer.writeAttribute("bindable", "true"); + if (!propertyNode->isWritable()) + writer.writeAttribute("writable", "false"); + if (!brief.isEmpty()) writer.writeAttribute("brief", brief); // Property access function names diff --git a/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index b/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index index a06a13ae7..802a9b6d5 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index +++ b/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index @@ -59,7 +59,7 @@ - + @@ -94,13 +94,13 @@ - + - + - + -- cgit v1.2.1