summaryrefslogtreecommitdiff
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
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>
-rw-r--r--src/qdoc/qdoc/qdocindexfiles.cpp5
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index8
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 @@
</function>
<function name="virtualFun" fullname="TestQDoc::Test::virtualFun" href="testqdoc-test.html#virtualFun" status="active" access="public" location="testcpp.h" documented="true" meta="plain" virtual="virtual" type="void" signature="void virtualFun()"/>
<typedef name="SomeType" fullname="TestQDoc::Test::SomeType" href="testqdoc-test.html#SomeType-typedef" status="active" access="public" location="testcpp.h" documented="true"/>
- <property name="id" fullname="TestQDoc::Test::id" href="testqdoc-test.html#id-prop" status="active" access="public" location="testcpp.h" documented="true"/>
+ <property name="id" fullname="TestQDoc::Test::id" href="testqdoc-test.html#id-prop" status="active" access="public" location="testcpp.h" documented="true" writable="false"/>
</class>
<class name="TestDerived" fullname="TestQDoc::TestDerived" href="testqdoc-testderived.html" status="active" access="public" location="testcpp.h" since="2.0" documented="true" bases="TestQDoc::Test" module="TestCPP" brief="A derived class in a namespace">
<function name="bindableProp" fullname="TestQDoc::TestDerived::bindableProp" href="testqdoc-testderived.html#bindableProp-prop" status="active" access="public" location="testcpp.h" meta="plain" associated-property="bindableProp" type="QBindable&lt;QString&gt;" signature="QBindable&lt;QString&gt; bindableProp()"/>
@@ -94,13 +94,13 @@
<resetter name="resetBoolProp"/>
<notifier name="boolPropChanged"/>
</property>
- <property name="intProp" fullname="TestQDoc::TestDerived::intProp" href="testqdoc-testderived.html#intProp-prop" status="active" access="public" location="testcpp.h" documented="true">
+ <property name="intProp" fullname="TestQDoc::TestDerived::intProp" href="testqdoc-testderived.html#intProp-prop" status="active" access="public" location="testcpp.h" documented="true" writable="false">
<getter name="getInt"/>
</property>
- <property name="name" fullname="TestQDoc::TestDerived::name" href="testqdoc-testderived.html#name-prop" status="active" access="public" location="testcpp.h" documented="true" brief="This property holds a name">
+ <property name="name" fullname="TestQDoc::TestDerived::name" href="testqdoc-testderived.html#name-prop" status="active" access="public" location="testcpp.h" documented="true" writable="false" brief="This property holds a name">
<getter name="name"/>
</property>
- <property name="someProp" fullname="TestQDoc::TestDerived::someProp" href="testqdoc-testderived.html#someProp-prop" status="active" access="public" location="testcpp.h" documented="true" bindable="true">
+ <property name="someProp" fullname="TestQDoc::TestDerived::someProp" href="testqdoc-testderived.html#someProp-prop" status="active" access="public" location="testcpp.h" documented="true" bindable="true" writable="false">
<getter name="someProp"/>
</property>
</class>