Replay: avoid recursion when adding subscriptions #24438
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved Problem
readAndAddSubscription
usesnextDataMessage
to find the first corresponding data andnextDataMessage
callsreadAndAddSubscription
when it finds a new message definition.This works but I don't think the recursion was done by design...
Solution
Sequentially add and setup each subscription without recursion.
The check for
msg_type == (int)ULogMessageType::ADD_LOGGED_MSG
also helps when some other messages exist at the same time, leading to strange output:Test coverage
Tested on a SITL log and a real flight from 1.16 (https://review.px4.io/plot_app?log=8863bef0-17e4-4315-b386-e1818d7d24f8)