Hi all,
I'm sending out some unsorted thoughts, hoping that you can help me
understand the issue I'm seeing.
After the switch to proto_tree_add_subtree(), I found that some output
of the DVB-CI dissector was different than before.
Replacing
ti = proto_tree_add_text(tree, tvb, offset, tvb_data_len, "Resource ID: 0x%04x", res_id);
res_tree = proto_item_add_subtree(ti, ett_dvbci_res);
with
res_tree = proto_tree_add_subtree_format(tree, tvb, offset, tvb_data_len,
ett_dvbci_res, &ti, "Resource ID: 0x%04x", res_id);
Does not give 100% identical behaviour. When tree!=NULL but not set to
visible, ti will be !=NULL in the fist case and ==NULL after the change
to proto_tree_add_subtree_format()
I came across this in a function that does something like
check if input is valid, return NULL on error
create proto_item from the input
create tree
populate tree
return proto_item
The caller would then check the returned proto_item for NULL to see if
the input could be processed. This started failing when
proto_tree_add_subtree_format() is used.
My gut feeling is that proto_tree_add_subtree_format() does the right
thing and I should fix my dissector...
However, I don't quite understand why for tree!=NULL but not visible,
proto_tree_add_text() returns tree. I can see this in the code, we call
TRY_TO_FAKE_THIS_ITEM(), which returns the tree itself when it's not
visible. But what sense does this make for the caller?
Best regards,
Martin