from_utf8(d->temppath.absFileName())));
}
- // Remove any previewed LaTeX snippets associated with this buffer.
if (!isClone())
- thePreviews().removeLoader(*this);
+ removePreviews();
delete d;
}
return readFile(tmpFile);
}
+ // InsetInfo needs to know if file is under VCS
+ lyxvc().file_found_hook(fn);
+
if (readDocument(lex)) {
Alert::error(_("Document format failure"),
bformat(_("%1$s ended unexpectedly, which means"
}
d->file_fully_loaded = true;
- // InsetInfo needs to know if file is under VCS
- lyxvc().file_found_hook(fn);
d->read_only = !fname.isWritable();
params().compressed = fname.isZippedFile();
+ saveCheckSum();
return ReadSuccess;
}
}
+void Buffer::updatePreviews() const
+{
+ if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
+ thePreviews().generateBufferPreviews(*this);
+}
+
+
+void Buffer::removePreviews() const
+{
+ thePreviews().removeLoader(*this);
+}
+
+
Buffer::ReadStatus Buffer::parseLyXFormat(Lexer & lex,
FileName const & fn, int & file_format) const
{
// see bug 6587
// removeAutosaveFile();
- saveCheckSum(d->filename);
+ saveCheckSum();
message(str + _(" done."));
return true;
}
-void Buffer::saveCheckSum(FileName const & file) const
+void Buffer::saveCheckSum() const
{
+ FileName const & file = d->filename;
if (file.exists()) {
d->timestamp_ = file.lastModified();
d->checksum_ = file.checksum();
}
InsetMath * im = iit->inset->asInsetMath();
- if (doing_export && im)
+ if (doing_export && im) {
InsetMathHull * hull = im->asHullInset();
if (hull)
hull->recordLocation(it);
+ }
if (iit->inset->lyxCode() != MATHMACRO_CODE)
continue;
ReadStatus const ret_llf = loadThisLyXFile(emergencyFile);
bool const success = (ret_llf == ReadSuccess);
if (success) {
- saveCheckSum(fn);
markDirty();
+ lyxvc().file_found_hook(fn);
str = _("Document was successfully recovered.");
} else
str = _("Document was NOT successfully recovered.");
// the file is not saved if we load the autosave file.
if (ret_llf == ReadSuccess) {
markDirty();
- saveCheckSum(fn);
+ lyxvc().file_found_hook(fn);
return ReadSuccess;
}
return ReadAutosaveFailure;
}
-bool Buffer::reload()
+Buffer::ReadStatus Buffer::reload()
{
setBusy(true);
// c.f. bug 6587
d->filename.refresh();
docstring const disp_fn = makeDisplayPath(d->filename.absFileName());
- bool const success = (loadLyXFile(d->filename) == ReadSuccess);
- if (success) {
+ ReadStatus const status = loadLyXFile(d->filename);
+ if (status == ReadSuccess) {
updateBuffer();
changed(true);
updateTitles();
markClean();
- saveCheckSum(d->filename);
message(bformat(_("Document %1$s reloaded."), disp_fn));
} else {
message(bformat(_("Could not reload document %1$s."), disp_fn));
}
setBusy(false);
- thePreviews().removeLoader(*this);
- if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
- thePreviews().generateBufferPreviews(*this);
+ removePreviews();
+ updatePreviews();
errors("Parse");
- return success;
+ return status;
}