things we will ultimately want to do separately.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36694
a592a061-630c-0410-9148-
cb99ea01b6c8
-void Buffer::checkBibInfoCache() const
+bool Buffer::isBibInfoCacheValid() const
+{
+ return d->bibinfo_cache_valid_;
+}
+
+
+void Buffer::checkIfBibInfoCacheIsValid() const
{
// use the master's cache
Buffer const * const tmp = masterBuffer();
if (tmp != this) {
{
// use the master's cache
Buffer const * const tmp = masterBuffer();
if (tmp != this) {
- tmp->checkBibInfoCache();
+ tmp->checkIfBibInfoCacheIsValid();
- // this will also reload the cache if it is invalid
- support::FileNameList const & bibfiles_cache = getBibfilesCache();
-
// compare the cached timestamps with the actual ones.
// compare the cached timestamps with the actual ones.
- support::FileNameList::const_iterator ei = bibfiles_cache.begin();
- support::FileNameList::const_iterator en = bibfiles_cache.end();
+ FileNameList const & bibfiles_cache = getBibfilesCache();
+ FileNameList::const_iterator ei = bibfiles_cache.begin();
+ FileNameList::const_iterator en = bibfiles_cache.end();
for (; ei != en; ++ ei) {
time_t lastw = ei->lastModified();
time_t prevw = d->bibfile_status_[*ei];
for (; ei != en; ++ ei) {
time_t lastw = ei->lastModified();
time_t prevw = d->bibfile_status_[*ei];
d->bibfile_status_[*ei] = lastw;
}
}
d->bibfile_status_[*ei] = lastw;
}
}
-
- // if not valid, then reload the info
- if (!d->bibinfo_cache_valid_) {
- d->bibinfo_.clear();
- fillWithBibKeys(d->bibinfo_);
- d->bibinfo_cache_valid_ = true;
+}
+
+
+void Buffer::reloadBibInfoCache() const
+{
+ // use the master's cache
+ Buffer const * const tmp = masterBuffer();
+ if (tmp != this) {
+ tmp->reloadBibInfoCache();
+ return;
+
+ checkIfBibInfoCacheIsValid();
+ if (d->bibinfo_cache_valid_)
+ return;
+
+ d->bibinfo_.clear();
+ fillWithBibKeys(d->bibinfo_);
+ d->bibinfo_cache_valid_ = true;
//FIXME: This does not work for child documents yet.
LASSERT(code == CITE_CODE, /**/);
//FIXME: This does not work for child documents yet.
LASSERT(code == CITE_CODE, /**/);
- // Check if the label 'from' appears more than once
- checkBibInfoCache();
+ // Check if the label 'from' appears more than once
BiblioInfo const & keys = masterBibInfo();
BiblioInfo::const_iterator bit = keys.begin();
BiblioInfo::const_iterator bend = keys.end();
BiblioInfo const & keys = masterBibInfo();
BiblioInfo::const_iterator bit = keys.begin();
BiblioInfo::const_iterator bend = keys.end();
// do this only if we are the top-level Buffer
if (master == this)
// do this only if we are the top-level Buffer
if (master == this)
// 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.
// 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.
void invalidateBibinfoCache() const;
/// This invalidates the cache of files we need to check.
void invalidateBibfileCache() const;
void invalidateBibinfoCache() const;
/// This invalidates the cache of files we need to check.
void invalidateBibfileCache() const;
- /// 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
- /// updateBuffer() and from GuiCitation.)
+ /// Updates the cached bibliography information, checking first to see
+ /// 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.
/// Note that this operates on the master document.
- void checkBibInfoCache() const;
+ 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;
/// \return the bibliography information for this buffer's master,
/// or just for it, if it isn't a child.
BiblioInfo const & masterBibInfo() const;
std::vector<std::string> backends() const;
///
void getLanguages(std::set<Language const *> &) const;
std::vector<std::string> backends() const;
///
void getLanguages(std::set<Language const *> &) const;
+ /// Checks whether any of the referenced bibfiles have changed since the
+ /// last time we loaded the cache. Note that this does NOT update the
+ /// cached information.
+ void checkIfBibInfoCacheIsValid() const;
/// Update the list of all bibfiles in use (including bibfiles
/// of loaded child documents).
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
/// Update the list of all bibfiles in use (including bibfiles
/// of loaded child documents).
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
BiblioInfo const & GuiCitation::bibInfo() const
{
BiblioInfo const & GuiCitation::bibInfo() const
{
- buffer().checkBibInfoCache();
- return buffer().masterBibInfo();
+ Buffer const & buf = buffer();
+ buf.reloadBibInfoCache();
+ return buf.masterBibInfo();