namespace {
-int const LYX_FORMAT = 336;
+int const LYX_FORMAT = 339; //rgh: removed modules
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
wa_->closeAll();
delete wa_;
}
+ delete inset;
}
BufferParams params;
// file, and then to construct the Buffer's bibinfo from that.
/// A cache for bibliography info
mutable BiblioInfo bibinfo_;
+ /// whether the bibinfo cache is valid
+ bool bibinfoCacheValid_;
/// Cache of timestamps of .bib files
map<FileName, time_t> bibfileStatus_;
mutable RefCache ref_cache_;
/// our Text that should be wrapped in an InsetText
- InsetText inset;
+ InsetText * inset;
};
: parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(false),
read_only(readonly_), filename(file), file_fully_loaded(false),
toc_backend(&parent), macro_lock(false), timestamp_(0),
- checksum_(0), wa_(0), undo_(parent)
+ checksum_(0), wa_(0), undo_(parent), bibinfoCacheValid_(false)
{
temppath = createBufferTmpDir();
lyxvc.setBuffer(&parent);
{
LYXERR(Debug::INFO, "Buffer::Buffer()");
- d->inset.setBuffer(*this);
- d->inset.initParagraphs(*this);
- d->inset.setAutoBreakRows(true);
- d->inset.getText(0)->setMacrocontextPosition(par_iterator_begin());
+ d->inset = new InsetText(*this);
+ d->inset->setAutoBreakRows(true);
+ d->inset->getText(0)->setMacrocontextPosition(par_iterator_begin());
}
// GuiView already destroyed
gui_ = 0;
+
+ // loop over children
+ Impl::BufferPositionMap::iterator it = d->children_positions.begin();
+ Impl::BufferPositionMap::iterator end = d->children_positions.end();
+ for (; it != end; ++it)
+ theBufferList().releaseChild(this, const_cast<Buffer *>(it->first));
+
// clear references to children in macro tables
d->children_positions.clear();
d->position_to_children.clear();
}
// Remove any previewed LaTeX snippets associated with this buffer.
- graphics::Previews::get().removeLoader(*this);
+ thePreviews().removeLoader(*this);
delete d;
}
Text & Buffer::text() const
{
- return const_cast<Text &>(d->inset.text_);
+ return d->inset->text();
}
Inset & Buffer::inset() const
{
- return const_cast<InsetText &>(d->inset);
+ return *d->inset;
}
params().fontsCJK.erase();
params().listings_params.clear();
params().clearLayoutModules();
+ params().clearRemovedModules();
params().pdfoptions().clear();
for (int i = 0; i < 4; ++i) {
}
// read main text
- bool const res = text().read(*this, lex, errorList, &(d->inset));
+ bool const res = text().read(*this, lex, errorList, d->inset);
updateMacros();
updateMacroInstances();
Lexer lex;
istringstream is(s);
lex.setStream(is);
- FileName const name = FileName::tempName();
+ FileName const name = FileName::tempName("Buffer_readString");
switch (readFile(lex, name, true)) {
case failure:
return false;
// lyx2lyx would fail
return wrongversion;
- FileName const tmpfile = FileName::tempName();
+ FileName const tmpfile = FileName::tempName("Buffer_readFile");
if (tmpfile.empty()) {
Alert::error(_("Conversion failed"),
bformat(_("%1$s is from a different"
}
catch (...) {
lyxerr << "Caught some really weird exception..." << endl;
- LyX::cref().exit(1);
+ lyx_exit(1);
}
ofs.close();
bibfiles.end());
}
}
+ // the bibinfo cache is now invalid
+ d->bibinfoCacheValid_ = false;
+}
+
+
+void Buffer::invalidateBibinfoCache()
+{
+ d->bibinfoCacheValid_ = false;
}
BiblioInfo const & Buffer::localBibInfo() const
{
- support::FileNameList const & bibfilesCache = getBibfilesCache();
- // compare the cached timestamps with the actual ones.
- bool changed = false;
- support::FileNameList::const_iterator ei = bibfilesCache.begin();
- support::FileNameList::const_iterator en = bibfilesCache.end();
- for (; ei != en; ++ ei) {
- time_t lastw = ei->lastModified();
- if (lastw != d->bibfileStatus_[*ei]) {
- changed = true;
- d->bibfileStatus_[*ei] = lastw;
- break;
+ if (d->bibinfoCacheValid_) {
+ support::FileNameList const & bibfilesCache = getBibfilesCache();
+ // compare the cached timestamps with the actual ones.
+ support::FileNameList::const_iterator ei = bibfilesCache.begin();
+ support::FileNameList::const_iterator en = bibfilesCache.end();
+ for (; ei != en; ++ ei) {
+ time_t lastw = ei->lastModified();
+ if (lastw != d->bibfileStatus_[*ei]) {
+ d->bibinfoCacheValid_ = false;
+ d->bibfileStatus_[*ei] = lastw;
+ break;
+ }
}
}
- if (changed) {
+ if (!d->bibinfoCacheValid_) {
+ d->bibinfo_.clear();
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
it->fillWithBibKeys(d->bibinfo_, it);
+ d->bibinfoCacheValid_ = true;
}
return d->bibinfo_;
}
}
+bool Buffer::isChild(Buffer * child) const
+{
+ return d->children_positions.find(child) != d->children_positions.end();
+}
+
+
template<typename M>
typename M::iterator greatest_below(M & m, typename M::key_type const & x)
{
string const error_type = (format == "program")
? "Build" : bufferFormat();
+ ErrorList & error_list = d->errorLists[error_type];
string const ext = formats.extension(format);
FileName const tmp_result_file(changeExtension(filename, ext));
bool const success = theConverters().convert(this, FileName(filename),
tmp_result_file, FileName(absFileName()), backend_format, format,
- errorList(error_type));
+ error_list);
// Emit the signal to show the error list.
if (format != backend_format)
errors(error_type);