summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2023-05-16 10:38:31 +0000
committerTopi Reinio <topi.reinio@qt.io>2023-05-16 11:39:28 +0000
commit3eae45a5d6b87a3d74f2240c5f172dc8be4a2270 (patch)
tree2db9b011912b7717a8178768dfcc8f49a179816c /src
parent00d6670f8c92843a6d881b414316f88f5adab994 (diff)
downloadqttools-3eae45a5d6b87a3d74f2240c5f172dc8be4a2270.tar.gz
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 <paul.wicking@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qdoc/qdoc/qdocindexfiles.cpp5
1 files changed, 5 insertions, 0 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