restore sort function pointers when restoring cfg #1762
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #1757
This PR fixes a sorting synchronization issue.
The root cause of the bug in #1757 is that the sorting function
entrycmpfn
is not restored when changing contexts, causingreverse
(andversion
) to be "global" in that setting them on one context caused them to be set on all contexts.This PR fixes the bug by setting
entrycmpfn
andnamecmpfn
to the correct pointers whenevercfg
is set.simulation of state variables in the bugged scenario:
cfg0.reverse = 0
,entrycmpfn = &entrycmp
r
cfg0.reverse = 1
,entrycmpfn = &reventrycmp
r
.cfg0.reverse = 1
,cfg1.reverse = 1
,entrycmpfn = &reventrycmp
r
in context 2.cfg0.reverse = 1
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
r
.cfg0.reverse = 1
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
r
again. no-ops when it should do something.cfg0.reverse = 0
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
the "double unset" behavior is because the statusbar uses a function pointer comparison to print
R
andV
. it does not usecfg.reverse
orcfg.version
. if the statusbar usedcfg.reverse
, we would seeR
in the statusbar, yet no reverse sort in the entrylist.video :)
nnn-bugfix.mp4