Please reply-all so that others on the mailing list can see...
On Tue, Feb 22, 2011 at 11:51 AM, James Mulvey
<james....@gmail.com> wrote:
1st issue is relatively easy to work around; I just call clear after construction.
Unfortunately that makes the second bug nasty; since then the outer message believes there is no change to the inner message when a modification is made to it.
This usage pattern is not really supposed to work. Sub-builders do not work like sub-messages in Python; they work like sub-messages in C++. So, setting a field on a sub-builder is not supposed to mark it present in the parent message, if it isn't present already. Basically, when you call clear(), you're saying "I am not using the sub-builders anymore", and you have to call getInnerBuilder() again to recreate the inner message. We should probably change the code to actually discard all sub-builders on clear().
Maybe explaining what I am doing will help:
I am writing transactional objects composed of an outer wrapper to two protobufs; all sets delegate to the delta message; all gets check the delta message and then the state.
Commit basically does state.mergeFrom(delta) and does dela.clear().
Rollback basically does delta.clear()
So with the second issue the outer object never records the change to the sub-object (and thus fails my unit test and use case)
I think this would work correctly if you didn't try to clear() immediately after getInnerBuilder().
I'm still mulling over the 1st issue.. There could be use cases where it is useful; but then having a get() mark it as dirty seems a little wrong.
Great work by the way!
Sent from my iPhone
The first issue is the intended behavior. It matches C++, where calling mutable_inner() instantiates the inner message. There needs to be a way to mark a sub-message "present" without actually setting any of its friends.
The second issue looks genuine, although it seems to me that it would cause no behavioral differences, only some wasted instructions. Is this correct?
2.4.0a is actually a "final" release. In fact, it is the successor to 2.4.0, which had a build problem. If there are significant bugs we can do a 2.4.0b or 2.4.1 to fix them.