mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
Proper fix now for bug #6846. The idea, due to JMarc, is to collect
bibliography information in updateBuffer(), rather than doing a wholly separate traversal. We still do a separate traversal in two cases, as a full updateBuffer() call just isn't needed there. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36696 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cff0f635cc
commit
66be58b074
@ -1809,8 +1809,21 @@ BiblioInfo const & Buffer::masterBibInfo() const
|
||||
}
|
||||
|
||||
|
||||
BiblioInfo & Buffer::masterBibInfo()
|
||||
{
|
||||
Buffer * tmp = const_cast<Buffer *>(masterBuffer());
|
||||
if (tmp != this)
|
||||
return tmp->masterBibInfo();
|
||||
return d->bibinfo_;
|
||||
}
|
||||
|
||||
|
||||
bool Buffer::isBibInfoCacheValid() const
|
||||
{
|
||||
// use the master's cache
|
||||
Buffer const * const tmp = masterBuffer();
|
||||
if (tmp != this)
|
||||
return tmp->isBibInfoCacheValid();
|
||||
return d->bibinfo_cache_valid_;
|
||||
}
|
||||
|
||||
@ -3845,7 +3858,7 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
|
||||
|
||||
// do this only if we are the top-level Buffer
|
||||
if (master == this)
|
||||
reloadBibInfoCache();
|
||||
checkIfBibInfoCacheIsValid();
|
||||
|
||||
// keep the buffers to be children in this set. If the call from the
|
||||
// master comes back we can see which of them were actually seen (i.e.
|
||||
|
@ -445,12 +445,16 @@ public:
|
||||
/// whether the cache is valid. If so, we do nothing. If not, then we
|
||||
/// reload all the BibTeX info.
|
||||
/// Note that this operates on the master document.
|
||||
/// Normally, this is done (more cheaply) in updateBuffer(), but there are
|
||||
/// times when we need to force it to be done and don't need a full buffer
|
||||
/// update. This is in GuiCitation and in changeRefsIfUnique() now.
|
||||
void reloadBibInfoCache() const;
|
||||
/// Was the cache valid the last time we checked?
|
||||
bool isBibInfoCacheValid() const;
|
||||
/// \return the bibliography information for this buffer's master,
|
||||
/// or just for it, if it isn't a child.
|
||||
BiblioInfo const & masterBibInfo() const;
|
||||
BiblioInfo & masterBibInfo();
|
||||
///
|
||||
void fillWithBibKeys(BiblioInfo & keys) const;
|
||||
///
|
||||
|
@ -334,6 +334,14 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
} else {
|
||||
autolabel_ = from_ascii("??");
|
||||
}
|
||||
if (!buffer().isBibInfoCacheValid()) {
|
||||
BiblioInfo bi = buffer().masterBibInfo();
|
||||
docstring const key = getParam("key");
|
||||
BibTeXInfo keyvalmap(false);
|
||||
keyvalmap.label(bibLabel());
|
||||
keyvalmap[from_ascii("ref")] = it.paragraph().asString();
|
||||
bi[key] = keyvalmap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,6 +234,15 @@ static string normalizeName(Buffer const & buffer,
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::updateBuffer(ParIterator const &, UpdateType)
|
||||
{
|
||||
if (buffer().isBibInfoCacheValid())
|
||||
return;
|
||||
BiblioInfo & bi = buffer().masterBibInfo();
|
||||
fillWithBibKeys(bi);
|
||||
}
|
||||
|
||||
|
||||
int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// the sequence of the commands:
|
||||
@ -669,9 +678,14 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
// This method returns a comma separated list of Bibtex entries
|
||||
void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
|
||||
InsetIterator const & /*di*/) const
|
||||
{
|
||||
fillWithBibKeys(keylist);
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist) const
|
||||
{
|
||||
// This bibtex parser is a first step to parse bibtex files
|
||||
// more precisely.
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
void updateBuffer(ParIterator const &, UpdateType);
|
||||
///
|
||||
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
@ -78,6 +80,8 @@ private:
|
||||
getBibTeXPath(docstring const & filename, Buffer const & buf);
|
||||
///
|
||||
void editDatabases() const;
|
||||
///
|
||||
void fillWithBibKeys(BiblioInfo &) const;
|
||||
|
||||
/// \name Private functions inherited from Inset class
|
||||
//@{
|
||||
|
Loading…
Reference in New Issue
Block a user