From: Richard Heck Date: Mon, 11 Jan 2010 16:29:26 +0000 (+0000) Subject: Check the bibliography cache only when we really need to do so. This (a) X-Git-Tag: 2.0.0~4422 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ce87e6767cdbcf5c424f2e9e0fdeb32d13376ab9;p=features.git Check the bibliography cache only when we really need to do so. This (a) prevents weirdness that might happen if the .bib file were to change during updateLabels(), (b) prevents even further weirdness that might happen if it changed during the output routines, and (c) ought to avoid slowness caused by the repeated calls to QFileInfo::refresh() needed to check the cache status. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32972 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index fbf288db42..5288a4f422 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1671,7 +1671,6 @@ BiblioInfo const & Buffer::masterBibInfo() const BiblioInfo const & Buffer::localBibInfo() const { - checkBibInfoCache(); return d->bibinfo_; } @@ -2822,6 +2821,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to, // Check if the label 'from' appears more than once vector labels; string paramName; + checkBibInfoCache(); BiblioInfo const & keys = masterBibInfo(); BiblioInfo::const_iterator bit = keys.begin(); BiblioInfo::const_iterator bend = keys.end(); @@ -3494,6 +3494,10 @@ void Buffer::updateLabels(UpdateScope scope, bool out) const // Use the master text class also for child documents Buffer const * const master = masterBuffer(); DocumentClass const & textclass = master->params().documentClass(); + + // do this only if we are the top-level Buffer + if (scope != UpdateMaster || master == this) + checkBibInfoCache(); // 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. diff --git a/src/Buffer.h b/src/Buffer.h index 6581313965..297e63208c 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -350,15 +350,23 @@ public: */ void validate(LaTeXFeatures &) const; - /// Update the cache with all bibfiles in use (including bibfiles + /// Update the list of all bibfiles in use (including bibfiles /// of loaded child documents). void updateBibfilesCache(UpdateScope scope = UpdateMaster) const; - /// - void invalidateBibinfoCache(); - /// Return the cache with all bibfiles in use (including bibfiles + /// Return the list with all bibfiles in use (including bibfiles /// of loaded child documents). support::FileNameList const & getBibfilesCache(UpdateScope scope = UpdateMaster) const; + /// Information from BibTeX databases is cached in the Buffer, so + /// we do not have to read the file over and over. + /// Calling this method invalidates the cache and so requires a + /// re-read. + void invalidateBibinfoCache(); + /// Updates the cached bibliography information. + /// Note that you MUST call this method to update the cache. It will + /// not happen otherwise. (Currently, it is called at the start of + /// updateLabels() and from GuiCitation.) + void checkBibInfoCache() const; /// \return the bibliography information for this buffer's master, /// or just for it, if it isn't a child. BiblioInfo const & masterBibInfo() const; @@ -571,8 +579,6 @@ private: void updateMacros(DocIterator & it, DocIterator & scope) const; /// - void checkBibInfoCache() const; - /// void setLabel(ParIterator & it) const; /// void collectRelatives(BufferSet & bufs) const; diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 7fc2cf5d99..4a55df9ffc 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -735,6 +735,7 @@ void GuiCitation::dispatchParams() BiblioInfo const & GuiCitation::bibInfo() const { + buffer().checkBibInfoCache(); return buffer().masterBibInfo(); }