Centralize preview generation/deletion code to Buffer::updatePreviews and Buffer::removePreviews.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35922 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-10-29 20:00:51 +00:00
parent 0c9da47505
commit eff06951a9
3 changed files with 22 additions and 7 deletions

View File

@ -414,9 +414,8 @@ Buffer::~Buffer()
from_utf8(d->temppath.absFileName())));
}
// Remove any previewed LaTeX snippets associated with this buffer.
if (!isClone())
thePreviews().removeLoader(*this);
removePreviews();
delete d;
}
@ -906,6 +905,19 @@ void Buffer::setFullyLoaded(bool value)
}
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
{
@ -4117,9 +4129,8 @@ Buffer::ReadStatus Buffer::reload()
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 status;
}

View File

@ -514,6 +514,11 @@ public:
/// Set by buffer_funcs' newFile.
void setFullyLoaded(bool);
/// Update the LaTeX preview snippets associated with this buffer
void updatePreviews() const;
/// Remove any previewed LaTeX snippets associated with this buffer
void removePreviews() const;
/// Our main text (inside the top InsetText)
Text & text() const;

View File

@ -308,8 +308,7 @@ BufferView::BufferView(Buffer & buf)
d->cursor_.resetAnchor();
d->cursor_.setCurrentFont();
if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
thePreviews().generateBufferPreviews(buffer_);
buffer_.updatePreviews();
}