#include "PreviewImage.h"
+#include "Buffer.h"
#include "Dimension.h"
#include "GraphicsImage.h"
#include "GraphicsLoader.h"
#include "support/FileName.h"
-#include "support/bind.h"
using namespace std;
using namespace lyx::support;
namespace lyx {
namespace graphics {
-class PreviewImage::Impl : public boost::signals::trackable {
+class PreviewImage::Impl {
public:
///
Impl(PreviewImage & p, PreviewLoader & l,
if (!image)
return dim;
- dim.asc = int(pimpl_->ascent_frac_ * double(image->height()));
+ dim.asc = int(pimpl_->ascent_frac_ * double(image->height()) + 0.5);
dim.des = image->height() - dim.asc;
dim.wid = image->width();
return dim;
}
-PreviewImage::Impl::Impl(PreviewImage & p, PreviewLoader & l,
- string const & s,
- FileName const & bf,
- double af)
- : parent_(p), ploader_(l), iloader_(bf),
+PreviewLoader & PreviewImage::previewLoader() const
+{
+ return pimpl_->ploader_;
+}
+
+
+PreviewImage::Impl::Impl(PreviewImage & p, PreviewLoader & l, string const & s,
+ FileName const & bf, double af)
+ : parent_(p), ploader_(l), iloader_(l.buffer().fileName(), bf),
snippet_(s), ascent_frac_(af)
{
- iloader_.connect(bind(&Impl::statusChanged, this));
+ iloader_.setDisplayPixelRatio(l.displayPixelRatio());
+ // This connection is destroyed at the same time as this.
+ iloader_.connect([this](){ statusChanged(); });
}
PreviewImage::Impl::~Impl()
{
- iloader_.filename().removeFile();
+ // If these images are generated for a clone, then that may be
+ // because we are previewing. We therefore do not want to delete
+ // them when this Buffer is destroyed.
+ if (!ploader_.buffer().isClone())
+ iloader_.filename().removeFile();
}