Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
312 stars 135 forks source link

Brewtarget crashes when exporting a recipe with a Sparge mash #626

Closed chmeeedalf closed 2 years ago

chmeeedalf commented 2 years ago

There's a comment in src/xml/BeerXml.cpp stating that flySparge and batchSparge get treated as Infusion when writing out to XML. However, it instead crashes with:

ERROR : void XmlRecord::toXml(const NamedEntity&, QTextStream&, int, const char*) const Could not find string representation of enum property type value "4" when writing < "TYPE" > field of MashStep [xml/XmlRecord.cpp:798]

Given the bidirectionality of the records (import and export), I'm not sure how best to resolve this so that it does get treated as the comment states.

matty0ung commented 2 years ago

Thanks for the bug report. I've done a patch (https://github.com/Brewtarget/brewtarget/pull/627) which should address this. The issue, as you mention, is that BeerXML does not support these mash step types, so we have to write them out as something else. When I first did the mapping code, it was for reading BeerXML, so it didn't have to handle these steps (because they will never appear in a valid BeerXML file). The patch adds them in to the mapping so that the comment you found remains true!

matty0ung commented 2 years ago

Actually, let me look at this a little further. I realised a flaw in the fix I posted and have now found another bug.

matty0ung commented 2 years ago

https://github.com/Brewtarget/brewtarget/pull/629 includes a better fix (so that an XML comment shows the original info about whether something written as infusion is actually flySparge or batchSparge).

mattiasmaahl commented 2 years ago

629 is merged, closing.

Please re-open if you still are experiencing this issue.

chmeeedalf commented 2 years ago

Thanks for fixing this! I just tested it and confirmed it's fixed.