mutable bool bibfile_cache_valid_;
/// Cache of timestamps of .bib files
map<FileName, time_t> bibfile_status_;
+ /// Indicates whether the bibinfo has changed since the last time
+ /// we ran updateBuffer(), i.e., whether citation labels may need
+ /// to be updated.
+ mutable bool cite_labels_valid_;
mutable RefCache ref_cache_;
read_only(readonly_), filename(file), file_fully_loaded(false),
toc_backend(owner), macro_lock(false), timestamp_(0),
checksum_(0), wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
- bibfile_cache_valid_(false), cloned_buffer_(cloned_buffer),
- doing_export(false), parent_buffer(0)
+ bibfile_cache_valid_(false), cite_labels_valid_(false),
+ cloned_buffer_(cloned_buffer), doing_export(false), parent_buffer(0)
{
if (!cloned_buffer_) {
temppath = createBufferTmpDir();
bibinfo_cache_valid_ = cloned_buffer_->d->bibinfo_cache_valid_;
bibfile_cache_valid_ = cloned_buffer_->d->bibfile_cache_valid_;
bibfile_status_ = cloned_buffer_->d->bibfile_status_;
+ cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_;
}
}
d->bibfile_cache_valid_ = true;
d->bibinfo_cache_valid_ = false;
+ d->cite_labels_valid_ = false;
}
void Buffer::invalidateBibinfoCache() const
{
d->bibinfo_cache_valid_ = false;
+ d->cite_labels_valid_ = false;
// also invalidate the cache for the parent buffer
Buffer const * const pbuf = d->parent();
if (pbuf)
{
d->bibfile_cache_valid_ = false;
d->bibinfo_cache_valid_ = false;
+ d->cite_labels_valid_ = false;
// also invalidate the cache for the parent buffer
Buffer const * const pbuf = d->parent();
if (pbuf)
time_t prevw = d->bibfile_status_[*ei];
if (lastw != prevw) {
d->bibinfo_cache_valid_ = false;
+ d->cite_labels_valid_ = false;
d->bibfile_status_[*ei] = lastw;
}
}
}
+bool Buffer::citeLabelsValid() const
+{
+ return masterBuffer()->d->cite_labels_valid_;
+}
+
+
bool Buffer::isDepClean(string const & name) const
{
DepClean::const_iterator const it = d->dep_clean.find(name);
return;
d->bibinfo_cache_valid_ = true;
+ d->cite_labels_valid_ = true;
cbuf.tocBackend().update();
if (scope == UpdateMaster)
cbuf.structureChanged();
#include "BufferParams.h"
#include "BufferView.h"
#include "DispatchResult.h"
+#include "FuncCode.h"
+#include "FuncRequest.h"
#include "LaTeXFeatures.h"
#include "output_xhtml.h"
#include "ParIterator.h"
}
+void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ if (cmd.action() == LFUN_INSET_MODIFY)
+ cache.recalculate = true;
+ InsetCommand::doDispatch(cur, cmd);
+}
+
+
docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
{
Buffer const & buf = bv.buffer();
void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
{
- CiteEngine const engine = buffer().params().citeEngine();
- if (cache.params == params() && cache.engine == engine)
+ if (!cache.recalculate && buffer().citeLabelsValid())
return;
- // The label has changed, so we have to re-create it.
+ // The label may have changed, so we have to re-create it.
docstring const glabel = generateLabel();
unsigned int const maxLabelChars = 45;
label += "...";
}
- cache.engine = engine;
- cache.params = params();
+ cache.recalculate = false;
cache.generated_label = glabel;
cache.screen_label = label;
}
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
+ ///
InsetCode lyxCode() const { return CITE_CODE; }
///
void latex(otexstream &, OutputParams const &) const;
static ParamInfo param_info_;
///
- class Cache {
- public:
- ///
- Cache() : engine(ENGINE_BASIC), params(CITE_CODE) {}
- ///
- CiteEngine engine;
+ struct Cache {
+ Cache() : recalculate(true) {};
///
- InsetCommandParams params;
+ bool recalculate;
///
docstring generated_label;
///