mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Towards a proper fix for bug #6846, this just disentangles a couple
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
This commit is contained in:
parent
4efd89fe83
commit
ab47822680
@ -1809,21 +1809,25 @@ BiblioInfo const & Buffer::masterBibInfo() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Buffer::checkBibInfoCache() const
|
bool Buffer::isBibInfoCacheValid() const
|
||||||
|
{
|
||||||
|
return d->bibinfo_cache_valid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Buffer::checkIfBibInfoCacheIsValid() const
|
||||||
{
|
{
|
||||||
// use the master's cache
|
// use the master's cache
|
||||||
Buffer const * const tmp = masterBuffer();
|
Buffer const * const tmp = masterBuffer();
|
||||||
if (tmp != this) {
|
if (tmp != this) {
|
||||||
tmp->checkBibInfoCache();
|
tmp->checkIfBibInfoCacheIsValid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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();
|
FileNameList const & bibfiles_cache = getBibfilesCache();
|
||||||
support::FileNameList::const_iterator en = bibfiles_cache.end();
|
FileNameList::const_iterator ei = bibfiles_cache.begin();
|
||||||
|
FileNameList::const_iterator en = bibfiles_cache.end();
|
||||||
for (; ei != en; ++ ei) {
|
for (; ei != en; ++ ei) {
|
||||||
time_t lastw = ei->lastModified();
|
time_t lastw = ei->lastModified();
|
||||||
time_t prevw = d->bibfile_status_[*ei];
|
time_t prevw = d->bibfile_status_[*ei];
|
||||||
@ -1832,13 +1836,25 @@ void Buffer::checkBibInfoCache() const
|
|||||||
d->bibfile_status_[*ei] = lastw;
|
d->bibfile_status_[*ei] = lastw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if not valid, then reload the info
|
|
||||||
if (!d->bibinfo_cache_valid_) {
|
void Buffer::reloadBibInfoCache() const
|
||||||
d->bibinfo_.clear();
|
{
|
||||||
fillWithBibKeys(d->bibinfo_);
|
// use the master's cache
|
||||||
d->bibinfo_cache_valid_ = true;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3014,9 +3030,9 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
|
|||||||
//FIXME: This does not work for child documents yet.
|
//FIXME: This does not work for child documents yet.
|
||||||
LASSERT(code == CITE_CODE, /**/);
|
LASSERT(code == CITE_CODE, /**/);
|
||||||
|
|
||||||
// Check if the label 'from' appears more than once
|
reloadBibInfoCache();
|
||||||
checkBibInfoCache();
|
|
||||||
|
|
||||||
|
// Check if the label 'from' appears more than once
|
||||||
BiblioInfo const & keys = masterBibInfo();
|
BiblioInfo const & keys = masterBibInfo();
|
||||||
BiblioInfo::const_iterator bit = keys.begin();
|
BiblioInfo::const_iterator bit = keys.begin();
|
||||||
BiblioInfo::const_iterator bend = keys.end();
|
BiblioInfo::const_iterator bend = keys.end();
|
||||||
@ -3829,7 +3845,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)
|
||||||
checkBibInfoCache();
|
reloadBibInfoCache();
|
||||||
|
|
||||||
// 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.
|
||||||
|
15
src/Buffer.h
15
src/Buffer.h
@ -441,12 +441,13 @@ public:
|
|||||||
void invalidateBibinfoCache() const;
|
void invalidateBibinfoCache() const;
|
||||||
/// This invalidates the cache of files we need to check.
|
/// This invalidates the cache of files we need to check.
|
||||||
void invalidateBibfileCache() const;
|
void invalidateBibfileCache() const;
|
||||||
/// Updates the cached bibliography information.
|
/// Updates the cached bibliography information, checking first to see
|
||||||
/// Note that you MUST call this method to update the cache. It will
|
/// whether the cache is valid. If so, we do nothing. If not, then we
|
||||||
/// not happen otherwise. (Currently, it is called at the start of
|
/// reload all the BibTeX info.
|
||||||
/// updateBuffer() and from GuiCitation.)
|
|
||||||
/// 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,
|
/// \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;
|
||||||
@ -660,6 +661,10 @@ private:
|
|||||||
std::vector<std::string> backends() const;
|
std::vector<std::string> backends() const;
|
||||||
///
|
///
|
||||||
void getLanguages(std::set<Language const *> &) 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
|
/// Update the list of all bibfiles in use (including bibfiles
|
||||||
/// of loaded child documents).
|
/// of loaded child documents).
|
||||||
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
||||||
|
@ -757,8 +757,9 @@ void GuiCitation::dispatchParams()
|
|||||||
|
|
||||||
BiblioInfo const & GuiCitation::bibInfo() const
|
BiblioInfo const & GuiCitation::bibInfo() const
|
||||||
{
|
{
|
||||||
buffer().checkBibInfoCache();
|
Buffer const & buf = buffer();
|
||||||
return buffer().masterBibInfo();
|
buf.reloadBibInfoCache();
|
||||||
|
return buf.masterBibInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user