http://bugzilla.lyx.org/show_bug.cgi?id=1486
Problem: Create a lyx document, enter $x^2$, wait for it to be previewed, now copy this formula and paste. The copied mathed will not be previewed, even if you move your cursor in and out. Diagnosis: In the copy constructor of InsetMathHull, preview_ is created without a latex snippet. Solution: In bool InsetMathHull::previewState(BufferView * bv) const, when an empty preview_ is encountered, get the latex code and add preview. NOTE: This is easier, and more natural, than tracking down when the inset is copied and addPreview there. After all, inset should take care of its own preview business. Waiting for two OKs. Cheers, Bo
Index: src/mathed/InsetMathHull.cpp =================================================================== --- src/mathed/InsetMathHull.cpp (revision 18839) +++ src/mathed/InsetMathHull.cpp (working copy) @@ -114,7 +114,15 @@ return numbered ? "" : "*"; } + docstring const latex_string(InsetMathHull const & inset) + { + odocstringstream ls; + WriteStream wi(ls, false, false); + inset.write(wi); + return ls.str(); + } + } // end anon namespace @@ -276,6 +284,11 @@ bool InsetMathHull::previewState(BufferView * bv) const { if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) { + // BUG 1486: preview_ of copied formula is empty + if (preview_->snippet_.empty()) { + docstring const snippet = latex_string(*this); + preview_->addPreview(snippet, *bv->buffer()); + } graphics::PreviewImage const * pimage = preview_->getPreviewImage(*bv->buffer()); return pimage && pimage->image(); @@ -395,19 +408,7 @@ } -namespace { -docstring const latex_string(InsetMathHull const & inset) -{ - odocstringstream ls; - WriteStream wi(ls, false, false); - inset.write(wi); - return ls.str(); -} - -} // namespace anon - - void InsetMathHull::addPreview(graphics::PreviewLoader & ploader) const { if (RenderPreview::status() == LyXRC::PREVIEW_ON) {