mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +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
|
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_;
|
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
|
// do this only if we are the top-level Buffer
|
||||||
if (master == this)
|
if (master == this)
|
||||||
reloadBibInfoCache();
|
checkIfBibInfoCacheIsValid();
|
||||||
|
|
||||||
// keep the buffers to be children in this set. If the call from the
|
// 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.
|
// 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
|
/// whether the cache is valid. If so, we do nothing. If not, then we
|
||||||
/// reload all the BibTeX info.
|
/// reload all the BibTeX info.
|
||||||
/// Note that this operates on the master document.
|
/// 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;
|
void reloadBibInfoCache() const;
|
||||||
/// Was the cache valid the last time we checked?
|
/// Was the cache valid the last time we checked?
|
||||||
bool isBibInfoCacheValid() const;
|
bool isBibInfoCacheValid() const;
|
||||||
/// \return the bibliography information for this buffer's master,
|
/// \return the bibliography information for this buffer's master,
|
||||||
/// or just for it, if it isn't a child.
|
/// or just for it, if it isn't a child.
|
||||||
BiblioInfo const & masterBibInfo() const;
|
BiblioInfo const & masterBibInfo() const;
|
||||||
|
BiblioInfo & masterBibInfo();
|
||||||
///
|
///
|
||||||
void fillWithBibKeys(BiblioInfo & keys) const;
|
void fillWithBibKeys(BiblioInfo & keys) const;
|
||||||
///
|
///
|
||||||
|
@ -334,6 +334,14 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
|
|||||||
} else {
|
} else {
|
||||||
autolabel_ = from_ascii("??");
|
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
|
int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
||||||
{
|
{
|
||||||
// the sequence of the commands:
|
// 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,
|
void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
|
||||||
InsetIterator const & /*di*/) const
|
InsetIterator const & /*di*/) const
|
||||||
|
{
|
||||||
|
fillWithBibKeys(keylist);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist) const
|
||||||
{
|
{
|
||||||
// This bibtex parser is a first step to parse bibtex files
|
// This bibtex parser is a first step to parse bibtex files
|
||||||
// more precisely.
|
// more precisely.
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
///
|
///
|
||||||
int latex(odocstream &, OutputParams const &) const;
|
int latex(odocstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
|
///
|
||||||
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
||||||
///
|
///
|
||||||
void validate(LaTeXFeatures &) const;
|
void validate(LaTeXFeatures &) const;
|
||||||
@ -78,6 +80,8 @@ private:
|
|||||||
getBibTeXPath(docstring const & filename, Buffer const & buf);
|
getBibTeXPath(docstring const & filename, Buffer const & buf);
|
||||||
///
|
///
|
||||||
void editDatabases() const;
|
void editDatabases() const;
|
||||||
|
///
|
||||||
|
void fillWithBibKeys(BiblioInfo &) const;
|
||||||
|
|
||||||
/// \name Private functions inherited from Inset class
|
/// \name Private functions inherited from Inset class
|
||||||
//@{
|
//@{
|
||||||
|
Loading…
Reference in New Issue
Block a user