Fix plLocation equality/comparison operators being inconsistent with each other#302
Fix plLocation equality/comparison operators being inconsistent with each other#302dgelessus wants to merge 5 commits into
plLocation equality/comparison operators being inconsistent with each other#302Conversation
|
Unfortunately, this change currently causes other issues, leading to PrpShop crashes in some cases... The In particular, I'm not sure what's the best way to fix this... It feels like we may need two different kinds of equality comparisons for locations: one to check if two locations are exactly the same or not (looking at all fields, including flags) and one to check if two locations conceptually refer to the same page (looking only at the state and age/page numbers). This would probably require changes to a lot of code that uses libHSPlasma, which is not great, but may be the safest move considering the previous inconsistent behavior... |
|
Actually, it looks like the affected |
Fixes some odd behavior in PrpShop when changing a PRP file's flags. Most likely this also caused other weirdness besides that.
To prevent any future inconsistencies between the two.
93bb3e3 to
26e57fc
Compare
Otherwise the plAgeInfo methods getPageLoc, getCommonPageLoc, and getPageLocs can no longer be used, because they return locations whose flags do not necessarily match the flags of the real corresponding pages (and those methods *cannot* be fixed to return the correct flags in the general case, because of the kItinerant flag, which cannot be predicted from other properties of the page). This fixes the crash when opening an .age file in PrpShop, caused by the preceding commits.
|
I've now implemented the first fix, by adding a new method that implements the previous behavior of This fixes the PrpShop crashes I encountered, but I'm not confident that this is a complete fix... Various other code still relies on the default comparison operators of |
In the current code, the
==,!=, and<operators forplLocationall look at different combinations of fields. In particular,==doesn't look atfFlagseven though!=does, and<doesn't look atfFlagsorfState. This PR makes all three operators consistent with each other.These buggy implementations led to some bad behavior when editing a PRP's flags in PrpShop, which seems to be fixed with this PR. This hopefully fixes the problems that @TheScarFr had when trying to change a PRP from reserved to non-reserved (I'm not completely sure, because I couldn't reproduce the bug exactly).
Apparently the buggy code has been this way for over 15 years? This seems really bad! I'm surprised that this hasn't caused any other problems with PRP edits before.
While I was here, I also replaced all
operator!=implementations withreturn !operator==(other);to prevent any future inconsistencies between==and!=, and addedoperator!=overloads to classes that only definedoperator==.