mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Andreas' patch to prevent crash on click on previewd inset
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10309 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fbd55b518a
commit
3410c395b5
@ -187,7 +187,7 @@ MathHullInset & MathHullInset::operator=(MathHullInset const & other)
|
||||
|
||||
InsetBase * MathHullInset::editXY(LCursor & cur, int x, int y)
|
||||
{
|
||||
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||
if (use_preview_) {
|
||||
edit(cur, true);
|
||||
return this;
|
||||
}
|
||||
@ -244,25 +244,24 @@ int MathHullInset::defaultColSpace(col_type col)
|
||||
|
||||
char const * MathHullInset::standardFont() const
|
||||
{
|
||||
if (type_ == "none")
|
||||
return "lyxnochange";
|
||||
return "mathnormal";
|
||||
return type_ == "none" ? "lyxnochange" : "mathnormal";
|
||||
}
|
||||
|
||||
|
||||
bool MathHullInset::previewState(BufferView * bv) const
|
||||
{
|
||||
if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||
lyx::graphics::PreviewImage const * pimage =
|
||||
preview_->getPreviewImage(*bv->buffer());
|
||||
return pimage && pimage->image();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
|
||||
|
||||
bool use_preview = false;
|
||||
if (!editing(mi.base.bv) &&
|
||||
RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||
lyx::graphics::PreviewImage const * pimage =
|
||||
preview_->getPreviewImage(*mi.base.bv->buffer());
|
||||
use_preview = pimage && pimage->image();
|
||||
}
|
||||
|
||||
if (use_preview) {
|
||||
if (previewState(mi.base.bv)) {
|
||||
preview_->metrics(mi, dim);
|
||||
// insert a one pixel gap in front of the formula
|
||||
dim.wid += 1;
|
||||
@ -306,17 +305,9 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void MathHullInset::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
|
||||
use_preview_ = previewState(pi.base.bv);
|
||||
|
||||
bool use_preview = false;
|
||||
if (!editing(pi.base.bv) &&
|
||||
RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||
lyx::graphics::PreviewImage const * pimage =
|
||||
preview_->getPreviewImage(*pi.base.bv->buffer());
|
||||
use_preview = pimage && pimage->image();
|
||||
}
|
||||
|
||||
if (use_preview) {
|
||||
if (use_preview_) {
|
||||
// one pixel gap in front
|
||||
preview_->draw(pi, x + 1, y);
|
||||
setPosCache(pi, x, y);
|
||||
|
@ -177,6 +177,8 @@ private:
|
||||
std::vector<std::string> label_;
|
||||
///
|
||||
boost::scoped_ptr<RenderPreview> preview_;
|
||||
///
|
||||
mutable bool use_preview_;
|
||||
//
|
||||
// Incorporate me
|
||||
//
|
||||
@ -202,9 +204,12 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
void handleFont(LCursor &, std::string const & arg, std::string const & font);
|
||||
void handleFont(LCursor & cur, std::string const & arg,
|
||||
std::string const & font);
|
||||
///
|
||||
void handleFont2(LCursor &, std::string const & arg);
|
||||
void handleFont2(LCursor & cur, std::string const & arg);
|
||||
///
|
||||
bool previewState(BufferView * bv) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -458,6 +458,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_FINISHED_DOWN:
|
||||
++cur.pos();
|
||||
cur.bv().cursor() = cur;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user