RetroPie / EmulationStation

A Fork of Emulation Station for RetroPie. Emulation Station is a flexible emulator front-end supporting keyboardless navigation and custom system themes.
Other
850 stars 340 forks source link

Fix for false "Save Changes" prompt on string compare of game rating. #860

Closed Gemba closed 5 months ago

Gemba commented 5 months ago

This one is not limited to the recent "folder edit" PR, but got evident as I was testing the rating edit. It turned out it is also present in the game metadata edit, before the "folder edit" PR. The issue has been hiding there for approx. 10 years.

Root cause is the conversion string -> float -> string in the RatingComponent (set/getValue()).

An unset<rating/> in the gamelist gets "0.0000" assigned as string (see Metadata.cpp), which in turn gets 0 (float) and when comparing the metadata value with the editor value on string basishasChanges() in GuiMetadataEd.cpp flags true (but should be false) as "0.0000" is not equal to "0".

My PR fell for the same cause, a default "" for absent folder ratings (see Metadata.cpp) will get 0 inside the RatingComponent but getValue() returns "0", again "" is not equal to "0" thus the prompt for "Save Changes", when leaving the Metadata Edit Dialog, is shown even if not needed.

Remediation is to initialize absent ratings with "0" and compare ratings on float basis. It catches also the more obscure cases f.i. of ".3" in a gamelist game rating and "0.3" returned from the RatingComponent.

pjft commented 5 months ago

Thank you.