On 04/18/2018 03:14 PM, Pavel Sanda wrote: > Pavel Sanda wrote: >> There is something weird going on with our section counters. >> When lyx crashes and leaves emergency file behind, in the next >> lyx run I choose for loading original and removing emergency file. >> The 'original' file is loaded but all counters are wrong, starting >> higher than they should ('5' in this case). > I have MWE. > 1. Save two attached files into single directory and cd there. > 2. $ touch paper.lyx.emergency > 3. $ lyx paper.lyx > 4. Hit 'Load Original' > 5. Hit 'Keep' > 6. Document is loaded, section counter does not start at 1. > > I have a feeling that I was capable to get similar behaviour even without > the emergency file, but can't reproduce it.
That is the weirdest bug I've seen in a long time. Looking at the code, I can't even imagine how it could happen, but it is totally reproducible. Also in 2.3.x. I added a little debug code to see what's happening when the counters are stepped. In the buggy case, I get this: Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 1 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): subsection Counters.cpp (303): 0 Counters.cpp (302): figure Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 2 Counters.cpp (302): section Counters.cpp (303): 3 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): subsection Counters.cpp (303): 0 Counters.cpp (302): figure Counters.cpp (303): 0 So for some reason, we are goign through the document a second time, but without resetting the counters. What's really weird, though, is that if I touch paper.lyx and bypass the emergency file, then I get this: Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 1 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): subsection Counters.cpp (303): 0 Counters.cpp (302): figure Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 2 Counters.cpp (302): section Counters.cpp (303): 3 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): subsection Counters.cpp (303): 0 Counters.cpp (302): figure Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): section Counters.cpp (303): 1 Counters.cpp (302): section Counters.cpp (303): 0 Counters.cpp (302): subsection Counters.cpp (303): 0 Counters.cpp (302): figure Counters.cpp (303): 0 So we actually did the same thing, but there's another trip through updateBuffer, it seems, that hides the bug! Weird. Riki