Make the FINAL attribute of QtProtobuf class properties configurable
- Since commit 9e49375dfa9d982a10316058b2f934ea648b7977,
QtProtobuf properties are generated with the FINAL specifier.
The FINAL specifier enables QML-tooling performance optimizations.
It also indicates that the property cannot be overridden in a
derived class.
Currently, all properties generated for user-defined QtProtobuf types
are marked as FINAL. However, the provided QtCoreTypes, QtGuiTypes,
and WellKnownTypes will continue to be generated without the FINAL
specifier until the next LTS release.
To preserve backwards compatibility, introduce the
'GENERATE_NON_FINAL_PROPERTIES' CMake / command-line option, which
restores the previous non-FINAL generation behavior when explicitly
requested.
Amends 9e49375dfa9d982a10316058b2f934ea648b7977
[ChangeLog][Important Behavior Changes] Generated QtProtobuf message
properties are now FINAL by default. A new GENERATE_NON_FINAL_PROPERTIES
option was added to restore the previous behavior for backwards
compatibility.
NOTE:
Using the FINAL is not the same as marking the entire C++ class as final.
The MOC does not expose a class-level final specifier to QML,
so QML-tooling cannot detect it and therefore cannot apply
the same optimizations.
Task-number: QTBUG-144005
Change-Id: I0b73311f5b909ea1c82c4334f7bc5ed1e077136a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
| commit | 364c47601942db03b7d9795ea3c614a75cd057f8 |
| parent | ec12d300f523a417da1a52c80b438c2784de0d46 |
| author | Tatiana Borisova <tatiana.borisova@qt.io> |
| committer | Tatiana Borisova <tatiana.borisova@qt.io> |
| commit time | Tue, 10 Mar 2026 17:45:15 +0100 |
- M src/protobuf/Qt6ProtobufBuildInternals.cmake
- M src/protobuf/doc/src/qt-add-protobuf.qdoc
- M src/protobuf/doc/src/qtprotobufgen.qdoc
- M src/tools/doc/qtprotoccommon.qdocinc
- M src/tools/qtprotobufgen/Qt6ProtobufToolsMacros.cmake
- M src/tools/qtprotobufgen/messagedeclarationprinter.cpp
- M src/tools/qtprotoccommon/commontemplates.cpp
- M src/tools/qtprotoccommon/commontemplates.h
- M src/tools/qtprotoccommon/options.cpp
- M src/tools/qtprotoccommon/options.h
- M src/wellknown/Qt6ProtobufWellKnownTypesBuildInternals.cmake
- M tests/auto/protobufgen/CMakeLists.txt
- A tests/auto/protobufgen/data/cmake_generated/non_final_properties/non-final-properties.qpb.cpp
- A tests/auto/protobufgen/data/cmake_generated/non_final_properties/non-final-properties.qpb.h
- A tests/auto/protobufgen/data/cmake_generated/non_final_properties/non-final-properties_qtprotoreg.cpp
- A tests/auto/protobufgen/data/cmd_line_generated/non_final_properties/non-final-properties.qpb.cpp
- A tests/auto/protobufgen/data/cmd_line_generated/non_final_properties/non-final-properties.qpb.h
- A tests/auto/protobufgen/data/cmd_line_generated/non_final_properties/non-final-properties_qtprotoreg.cpp
- A tests/auto/protobufgen/data/non-final-properties.proto
- M tests/auto/protobufgen/tst_qtprotobufgen.cpp