mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Don't use the cached BufferView to get the Buffer when we have direct access
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7886 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b5b225c657
commit
8ddfa9d784
@ -1,3 +1,9 @@
|
|||||||
|
2003-10-09 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* PreviewedInset.[Ch] (removePreview, previewReady): these functions
|
||||||
|
are now passed a 'Buffer const &', eliminating most of the remaining
|
||||||
|
need for PreviewedInset to use a BufferView cache.
|
||||||
|
|
||||||
2003-10-07 Martin Vermeer <martin.vermeer@hut.fi>
|
2003-10-07 Martin Vermeer <martin.vermeer@hut.fi>
|
||||||
|
|
||||||
* GraphicsCache.h:
|
* GraphicsCache.h:
|
||||||
|
@ -75,8 +75,8 @@ void PreviewedInset::addPreview(PreviewLoader & ploader)
|
|||||||
// If this is the first time of calling, connect to the
|
// If this is the first time of calling, connect to the
|
||||||
// PreviewLoader signal that'll inform us when the preview image
|
// PreviewLoader signal that'll inform us when the preview image
|
||||||
// is ready for loading.
|
// is ready for loading.
|
||||||
if (!connection_.connected()) {
|
if (!ploader_connection_.connected()) {
|
||||||
connection_ = ploader.connect(
|
ploader_connection_ = ploader.connect(
|
||||||
boost::bind(&PreviewedInset::imageReady, this, _1));
|
boost::bind(&PreviewedInset::imageReady, this, _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,43 +84,36 @@ void PreviewedInset::addPreview(PreviewLoader & ploader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreviewedInset::removePreview()
|
void PreviewedInset::removePreview(Buffer const & buffer)
|
||||||
{
|
{
|
||||||
if (!view() || !view()->buffer() || snippet_.empty())
|
if (snippet_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Previews & previews = Previews::get();
|
Previews & previews = Previews::get();
|
||||||
PreviewLoader & loader = previews.loader(*view()->buffer());
|
PreviewLoader & loader = previews.loader(buffer);
|
||||||
loader.remove(snippet_);
|
loader.remove(snippet_);
|
||||||
snippet_.erase();
|
snippet_.erase();
|
||||||
pimage_ = 0;
|
pimage_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PreviewedInset::previewReady() const
|
bool PreviewedInset::previewReady(Buffer const & buffer) const
|
||||||
{
|
{
|
||||||
if (!Previews::activated() || !view() || !view()->buffer())
|
if (!Previews::activated() || !previewWanted(buffer))
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!previewWanted(*view()->buffer()))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!pimage_ || snippet_ != pimage_->snippet()) {
|
if (!pimage_ || snippet_ != pimage_->snippet()) {
|
||||||
PreviewLoader & ploader =
|
PreviewLoader & ploader = Previews::get().loader(buffer);
|
||||||
Previews::get().loader(*view()->buffer());
|
|
||||||
pimage_ = ploader.preview(snippet_);
|
pimage_ = ploader.preview(snippet_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pimage_)
|
return pimage_ ? pimage_->image() : false;
|
||||||
return false;
|
|
||||||
|
|
||||||
return pimage_->image();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreviewedInset::imageReady(PreviewImage const & pimage) const
|
void PreviewedInset::imageReady(PreviewImage const & pimage) const
|
||||||
{
|
{
|
||||||
// Check snippet against the Inset's current contents
|
// Check the current snippet is the same as that previewed.
|
||||||
if (snippet_ != pimage.snippet())
|
if (snippet_ != pimage.snippet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ public:
|
|||||||
/** Remove a snippet from the cache of previews.
|
/** Remove a snippet from the cache of previews.
|
||||||
* Useful if previewing the contents of a file that has changed.
|
* Useful if previewing the contents of a file that has changed.
|
||||||
*/
|
*/
|
||||||
void removePreview();
|
void removePreview(Buffer const &);
|
||||||
|
|
||||||
/// The preview has been generated and is ready to use.
|
/// The preview has been generated and is ready to use.
|
||||||
bool previewReady() const;
|
bool previewReady(Buffer const &) const;
|
||||||
|
|
||||||
/// If !previewReady() returns 0.
|
/// If !previewReady() returns 0.
|
||||||
PreviewImage const * pimage() const;
|
PreviewImage const * pimage() const;
|
||||||
@ -83,8 +83,10 @@ private:
|
|||||||
|
|
||||||
/// We don't own this. Cached for efficiency reasons.
|
/// We don't own this. Cached for efficiency reasons.
|
||||||
mutable PreviewImage const * pimage_;
|
mutable PreviewImage const * pimage_;
|
||||||
///
|
/** Store the connection to the preview loader so that we connect
|
||||||
boost::signals::connection connection_;
|
* only once.
|
||||||
|
*/
|
||||||
|
boost::signals::connection ploader_connection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2003-10-09 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* insetinclude.C (metrics, draw, restartLoading): pass a buffer arg
|
||||||
|
to PreviewedInset's previewReady and removePreview member functions.
|
||||||
|
|
||||||
2003-10-08 André Pönitz <poenitz@gmx.net>
|
2003-10-08 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
@ -538,7 +538,8 @@ void InsetInclude::fillWithBibKeys(Buffer const & buffer,
|
|||||||
|
|
||||||
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
if (preview_->previewReady()) {
|
Buffer const * buffer_ptr = mi.base.bv ? mi.base.bv->buffer() : 0;
|
||||||
|
if (buffer_ptr && preview_->previewReady(*buffer_ptr)) {
|
||||||
dim.asc = preview_->pimage()->ascent();
|
dim.asc = preview_->pimage()->ascent();
|
||||||
dim.des = preview_->pimage()->descent();
|
dim.des = preview_->pimage()->descent();
|
||||||
dim.wid = preview_->pimage()->width();
|
dim.wid = preview_->pimage()->width();
|
||||||
@ -563,7 +564,10 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
cache(pi.base.bv);
|
cache(pi.base.bv);
|
||||||
if (!preview_->previewReady()) {
|
Buffer const * buffer_ptr = pi.base.bv ? pi.base.bv->buffer() : 0;
|
||||||
|
bool const use_preview = buffer_ptr && preview_->previewReady(*buffer_ptr);
|
||||||
|
|
||||||
|
if (!use_preview) {
|
||||||
button_.draw(pi, x + button_.box().x1, y);
|
button_.draw(pi, x + button_.box().x1, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -626,12 +630,14 @@ void InsetInclude::PreviewImpl::startMonitoring(string const & file)
|
|||||||
|
|
||||||
void InsetInclude::PreviewImpl::restartLoading()
|
void InsetInclude::PreviewImpl::restartLoading()
|
||||||
{
|
{
|
||||||
removePreview();
|
|
||||||
if (!view())
|
if (!view())
|
||||||
return;
|
return;
|
||||||
view()->updateInset(&parent());
|
view()->updateInset(&parent());
|
||||||
if (view()->buffer())
|
if (view()->buffer()) {
|
||||||
generatePreview(*view()->buffer());
|
Buffer const & buffer = *view()->buffer();
|
||||||
|
removePreview(buffer);
|
||||||
|
generatePreview(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2003-10-09 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* formula.C (metrics, draw): pass a buffer arg to PreviewedInset's
|
||||||
|
previewReady and removePreview member functions.
|
||||||
|
|
||||||
2003-10-07 André Pönitz <poenitz@gmx.net>
|
2003-10-07 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "math_mathmlstream.h"
|
#include "math_mathmlstream.h"
|
||||||
#include "textpainter.h"
|
#include "textpainter.h"
|
||||||
|
|
||||||
|
#include "BufferView.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "latexrunparams.h"
|
#include "latexrunparams.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
@ -195,7 +196,8 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
|||||||
cache(pi.base.bv);
|
cache(pi.base.bv);
|
||||||
// This initiates the loading of the preview, so should come
|
// This initiates the loading of the preview, so should come
|
||||||
// before the metrics are computed.
|
// before the metrics are computed.
|
||||||
bool const use_preview = preview_->previewReady();
|
Buffer const * buffer_ptr = pi.base.bv ? pi.base.bv->buffer() : 0;
|
||||||
|
bool const use_preview = buffer_ptr && preview_->previewReady(*buffer_ptr);
|
||||||
|
|
||||||
int const w = dim_.wid;
|
int const w = dim_.wid;
|
||||||
int const d = dim_.des;
|
int const d = dim_.des;
|
||||||
@ -260,7 +262,8 @@ bool InsetFormula::insetAllowed(InsetOld::Code code) const
|
|||||||
void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
|
void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
|
||||||
{
|
{
|
||||||
view_ = m.base.bv;
|
view_ = m.base.bv;
|
||||||
if (preview_->previewReady()) {
|
Buffer const * buffer_ptr = m.base.bv ? m.base.bv->buffer() : 0;
|
||||||
|
if (buffer_ptr && preview_->previewReady(*buffer_ptr)) {
|
||||||
dim.asc = preview_->pimage()->ascent();
|
dim.asc = preview_->pimage()->ascent();
|
||||||
dim.des = preview_->pimage()->descent();
|
dim.des = preview_->pimage()->descent();
|
||||||
// insert a one pixel gap in front of the formula
|
// insert a one pixel gap in front of the formula
|
||||||
|
Loading…
Reference in New Issue
Block a user