qtgrpc/tests/auto/protobuf
Alexey Edelev d6586d97a1 Long live mutable getters
The functionality is desirable by some users, we re-enable it.
New API addresses the core issue that is partially related to
QTBUG-119912, but has wider concequences in blind use in user
projects. We add the 'mut' prefix to all mutable getters to make
the mutable access explicit. Overload approach leads to unwanted
detaches not only whe is used be moc-generated code, but also
in user projects if developers do not pay enough attention to
const modifiers of their variables/references. We declined to
restore it, dispite it was the better looking API, in favor to
the code safety.

This also reveals the code clashing scenario, when the overload
might happen if the message has both 'a' and 'mutA' fields in
its definition. This scenario is kindly forbidden by our generator,
and sanitized at very early stages. We expect that it won't happen
in user projects, but even if it will, the solution is to rename
the field when generating Qt code. The serialization/deserialization
do not depend on field naming directly. json_name attribute also
will help to workaround this.

The undocumented ALLOW_MUTABLE_GETTER_CONFLICTS option allows clashing
the mutable getter names, but its usage currently limited by our
internal code only. The reason unfixed QTBUG-119912 issue in moc.
Once the issue is fixed, the moc version check should get the proper
version, but not '99' as for now and the ALLOW_MUTABLE_GETTER_CONFLICTS
will become public.

Another design solution is the use of overloaded functions that
return pointers, like it's done it the reference protobuf. But this
kind of API leaves the pointer ownership undefined and decided to
not be used.

[ChangeLog][Protobuf] The generated messages now have the mutable
getters for the fiels of the message type. The getters have 'mut'
prefix and implicily allocate the respective fields if needed, so the
use of intermediate message objects is not required.

Task-number: QTBUG-119913
Change-Id: I09b9ee37e1fbbe37b9c3cb501e92442da8ad3e4b
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-04-04 17:45:22 +02:00
..
basic Long live mutable getters 2025-04-04 17:45:22 +02:00
conformance Doc: Split up protobuf attributions between tools and tests 2025-01-28 17:33:28 +01:00
converters Rename the TransparentWrapper::_t member to t 2024-08-03 11:18:12 +02:00
duplicated_metatypes Support QT_NO_SIGNALS_SLOTS_KEYWORDS 2024-05-21 14:19:44 +02:00
enums Avoid generating QList aliases for the protobuf messages 2024-12-16 09:57:33 +01:00
externalpackage Avoid generating QList aliases for the protobuf messages 2024-12-16 09:57:33 +01:00
extranamespace Support QT_NO_SIGNALS_SLOTS_KEYWORDS 2024-05-21 14:19:44 +02:00
json Generalize deserializer in protobuf and JSON serializers 2024-12-16 09:57:48 +01:00
nested Remove 'get' prefixes of QProtobufPropertyOrdering methods 2024-08-02 16:58:32 +02:00
nopackage Remove 'get' prefixes of QProtobufPropertyOrdering methods 2024-08-02 16:58:32 +02:00
optional Support QT_NO_SIGNALS_SLOTS_KEYWORDS 2024-05-21 14:19:44 +02:00
qprotobuflazymessagepointer Adjust protobuf constrains across repo code 2024-08-28 14:47:48 +02:00
qprotobufoneof Avoid pointer-based overload of QProtobufOneof::value 2024-08-19 13:14:35 +02:00
qprotobufpropertyorderingbuilder Remove 'get' prefixes of QProtobufPropertyOrdering methods 2024-08-02 16:58:32 +02:00
recursive Support QT_NO_SIGNALS_SLOTS_KEYWORDS 2024-05-21 14:19:44 +02:00
sequence Avoid generating QList aliases for the protobuf messages 2024-12-16 09:57:33 +01:00
shared Remove 'get' prefixes of QProtobufPropertyOrdering methods 2024-08-02 16:58:32 +02:00
syntax Long live mutable getters 2025-04-04 17:45:22 +02:00
transparentwrapper Add the test for qbswap function of QtProtobuf::TransparentWrapper 2024-08-23 13:32:51 +02:00
wellknown Add custom JSON serializer for google.protobuf.Duration 2025-01-17 18:14:56 +01:00
CMakeLists.txt Add qHash implementation for the QtProtobuf::TransparentWrapper 2024-08-23 13:32:51 +02:00