ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Bug Reports (https://www.esoui.com/forums/forumdisplay.php?f=187)
-   -   [fixed] Faulty code in ZO_SortHeaderGroup:OnHeaderClicked (https://www.esoui.com/forums/showthread.php?t=6530)

code65536 09/26/16 04:17 PM

[fixed] Faulty code in ZO_SortHeaderGroup:OnHeaderClicked
 
There is a problem in the ZO_SortHeaderGroup:OnHeaderClicked function (found in \esoui\libraries\zo_sortheadergroup\zo_sortheadergroup.lua), specifically, with the following line of code:

Code:

        self.sortDirection = resetSortDir and header.initialDirection or not self.sortDirection
The "condition and a or b" shorthand in Lua is subject to one crucial caveat: the "a" term must never be nil or false. If it is, then "b" will always be used, regardless of what "condition" evaluates to.

In this case, since the sort directions are stored as either true or false, this line of code returns the incorrect result if resetSortDir is true and initialDirection is down (false). This code must be replaced with if-then longhand (reversing the condition and swapping a and b will suffer the same problem).

You can see this bug in action if you try to use SelectAndResetSortForKey on a column that has a downward initial sort direction.

(Also, it might be a good idea to audit the code for more instances of these "condition and a or b" shorthands--this is a subtle and easily-missed error, and there could be other places that might have similar problems.)

Ayantir 09/26/16 06:11 PM

For bugs, consider /bug

It saves jobs & process :)

ZOS_ChipHilseberg 09/27/16 08:00 AM

I feel like this was reported before but I forgot to fix it. Well, it's fixed now. It will be part of the next package.

merlight 09/27/16 06:57 PM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 28419)
I feel like this was reported before but I forgot to fix it. Well, it's fixed now. It will be part of the next package.

Yes, I've reported that here


All times are GMT -6. The time now is 03:20 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI