Juergen Spitzmueller wrote:
I digged a bit further into this, and it turned out that, if the previewed inset is empty (thus no png is generated), the value of ascent_fraction in the lyxpreview.metrics file is set to the rather ridiculous value of
-2147483646.000000
This leads, of course, to huge ascent() and descent() values, which just let the metrics explode.

The attached patch is a kind of a workaround, but there certainly must be a better solution. Personally, I'd prefer to just not preview empty mathinsets (they tend to get pretty invisible), but I didn't manage to do this.

Angus, do you have any idea?

Make the addPreview call conditional on "snippet" not being empty:

void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
{
        if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
                string const snippet = latex_string(*this);
                preview_->addPreview(snippet, ploader);
        }
}


void MathHullInset::notifyCursorLeaves(LCursor & cur)
{
        if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
                Buffer const & buffer = cur.buffer();
                string const snippet = latex_string(*this);
                preview_->addPreview(snippet, buffer);
                preview_->startLoading(buffer);
        }
}

Reply via email to