On 04/12/2010 23:55, Richard Heck wrote:
On 12/04/2010 03:41 PM, Abdelrazak Younes wrote:
On 04/12/2010 04:15, rgh...@lyx.org wrote:
Author: rgheck
Date: Sat Dec 4 04:15:53 2010
New Revision: 36710
URL: http://www.lyx.org/trac/changeset/36710
Log:
Revert r36696: We can't collect BibTeX information during the
updateBuffer() traversal. The reason is simple: InsetCitation needs
access to the BibTeX info to calculate its label. But we won't have it
until we get to the bibliography.
I don't think there is any way around that.
Couldn't we just pass until it gets loaded? I don't see how this is
any different than reference and labels... maybe I am wrong but it
should be as simple as coming back to the InsetCitation in
InsetBibtex::updateBuffe().
How do we go back to the InsetCitation once we have already passed it?
I mean, on that trip through? How do we know when all the bibliography
information has been loaded? We can't until we are done. So the only
thing I can see would be to collect pointers to all the InsetCitations
and then do them all at the end. I don't see anything similar with
references and labels. Their screen labels do not depend upon anything
else.
We _do_ something similar with references and labels: see
Buffer::references() and Buffer::setInsetLabel().
Consider in particular the very first time we call updateBuffer().
Then when we do this test:
BiblioInfo const & biblist = buf.masterBibInfo();
if (biblist.empty())
return docstring();
in InsetCitation::complexLabel(), biblist will indeed be empty,
because it hasn't yet been filled. Since the citations normally come
before the bibliography, none of them will get "complex" labels the
first time.
If we were to collect pointers to all the InsetCitations we would update
their labels in one shot at the end of Buffer::updateBuffer(). I hope
your understand what I mean.
They also don't get new ones later, since we cache the label and only
change it in certain cases.
Here again, maybe these "certain cases" could be factorized in the
generalized routine described above. Maybe (just maybe) this would also
simplify a bit the bib cache code.
Abdel.