Skip to content

Conversation

@JoePfeiffer
Copy link
Contributor

@JoePfeiffer JoePfeiffer commented Feb 25, 2025

The Warning class has five subclasses: LargeAOA, HighSpeedDeployment, EventAfterLanding, MissingMotor, and Other.

At present, when a Warning is saved to a .ork file, only its descriptive text, UUID, and priority are saved (regardless of subclass). When it is read, the text is used to create a Warning.Other containing this text. The basic problem with #2694 was that if two warnings with identical text were saved in a .ork, one could be lost when reading it back.

This PR saves Warnings from each subclass as that subclass, and then reconstructs it when reading the .ork. The <warning> element is replaced with a <warning type="LargeAOA"> or other subclass type; those that have parameters save the parameters as well.

There are also several fixes to adding warnings to the WarningSet.

Note: after merging this PR, all 23.09 (and earlier) .ork files can be read without error. Some files saved by 24.12 beta 01 that contain warnings will have warnings about unknown attributes as an "id" attribute has been renamed "warnid". It seems to me this minor breakage (remember, it actually successfully reads it just with the warning) is acceptable for files saved by a beta.

Note 2: MissingMotor Warnings are never saved to the .ork file, so reading and writing them is not supported by this PR.

Fixes #2694

… WarningSet and then merging that back in to the "master" WarningSet in the FlightData, put new Warnings in FlightData WarningSet in the first place
…ava Collection

Replacing an element with the new element is not regarded as a change, so it returns false
… than the entire warning so any pointers to the old Message remain valid.

Note that the only subclass of Message that can ever return true for replaceBy() is Warning.LargeAOA, and due to the interaction between this warning, the tumble stepper, and tumble under thrust aborts I'm not sure there any circumstances under which it might, either.
…ther

Also updates sim warning in simple model rocket example
@JoePfeiffer JoePfeiffer changed the title Save and Read Warnings With Correct Subclass, not Other Save and Read Warnings With Correct Subclass, not "Other" Feb 25, 2025
@JoePfeiffer JoePfeiffer merged commit 4fe2b3b into openrocket:unstable Mar 3, 2025
1 check passed
@JoePfeiffer JoePfeiffer deleted the fix-2694 branch March 10, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] warnings can be duplicated, then saved .ork fails to load

1 participant