commit b1323be32cac3289c33920ce001d935e43ad1b0e
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Wed Feb 3 14:50:00 2016 +0100
Get rid of use_preview_ in various insets
This concerns InsetPreview, InsetIPA and InsetMathHull.
Caching such a value is bad when opening the same buffer in two views.
In this case, it is not necessary to remember use_preview_ at all,
actually.
Also remove private member dim_ which is not used and remove some trailing
whitespace.
Fixes bugs #9085 abd #9957.
diff --git a/src/insets/InsetIPA.cpp b/src/insets/InsetIPA.cpp
index 6fe0a90..9e21959 100644
--- a/src/insets/InsetIPA.cpp
+++ b/src/insets/InsetIPA.cpp
@@ -37,7 +37,7 @@ namespace lyx {
InsetIPA::InsetIPA(Buffer * buf)
: InsetText(buf),
- preview_(new RenderPreview(this)), use_preview_(true)
+ preview_(new RenderPreview(this))
{
setAutoBreakRows(true);
setDrawFrame(true);
@@ -141,9 +141,7 @@ void InsetIPA::reloadPreview(DocIterator const & pos) const
void InsetIPA::draw(PainterInfo & pi, int x, int y) const
{
- use_preview_ = previewState(pi.base.bv);
-
- if (use_preview_) {
+ if (previewState(pi.base.bv)) {
preview_->draw(pi, x + TEXT_TO_INSET_OFFSET, y);
setPosCache(pi, x, y);
return;
@@ -161,7 +159,7 @@ void InsetIPA::edit(Cursor & cur, bool front,
EntryDirection entry_from)
Inset * InsetIPA::editXY(Cursor & cur, int x, int y)
{
- if (use_preview_) {
+ if (previewState(&cur.bv())) {
edit(cur, true, ENTRY_DIRECTION_IGNORE);
return this;
}
@@ -182,7 +180,6 @@ void InsetIPA::metrics(MetricsInfo & mi, Dimension & dim)
const
dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += TEXT_TO_INSET_OFFSET;
- dim_ = dim;
dim.wid += TEXT_TO_INSET_OFFSET;
// insert a one pixel gap
dim.wid += 1;
diff --git a/src/insets/InsetIPA.h b/src/insets/InsetIPA.h
index 4688696..13b8f0b 100644
--- a/src/insets/InsetIPA.h
+++ b/src/insets/InsetIPA.h
@@ -90,12 +90,6 @@ protected:
///
boost::scoped_ptr<RenderPreview> preview_;
- ///
- mutable bool use_preview_;
-
-private:
- ///
- mutable Dimension dim_;
};
diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp
index 6e9db8c..730fc6d 100644
--- a/src/insets/InsetPreview.cpp
+++ b/src/insets/InsetPreview.cpp
@@ -35,9 +35,8 @@ using namespace std;
namespace lyx {
-InsetPreview::InsetPreview(Buffer * buf)
- : InsetText(buf),
- preview_(new RenderPreview(this)), use_preview_(true)
+InsetPreview::InsetPreview(Buffer * buf)
+ : InsetText(buf), preview_(new RenderPreview(this))
{
setAutoBreakRows(true);
setDrawFrame(true);
@@ -45,7 +44,7 @@ InsetPreview::InsetPreview(Buffer * buf)
}
-InsetPreview::~InsetPreview()
+InsetPreview::~InsetPreview()
{}
@@ -70,7 +69,7 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
}
-void InsetPreview::preparePreview(DocIterator const & pos) const
+void InsetPreview::preparePreview(DocIterator const & pos) const
{
TexRow texrow;
odocstringstream str;
@@ -128,15 +127,12 @@ void InsetPreview::reloadPreview(DocIterator const & pos)
const
void InsetPreview::draw(PainterInfo & pi, int x, int y) const
{
- use_preview_ = previewState(pi.base.bv);
-
- if (use_preview_) {
+ if (previewState(pi.base.bv)) {
// one pixel gap in front
preview_->draw(pi, x + 1 + TEXT_TO_INSET_OFFSET, y);
setPosCache(pi, x, y);
- return;
- }
- InsetText::draw(pi, x, y);
+ } else
+ InsetText::draw(pi, x, y);
}
@@ -149,7 +145,7 @@ void InsetPreview::edit(Cursor & cur, bool front,
EntryDirection entry_from)
Inset * InsetPreview::editXY(Cursor & cur, int x, int y)
{
- if (use_preview_) {
+ if (previewState(&cur.bv())) {
edit(cur, true, ENTRY_DIRECTION_IGNORE);
return this;
}
@@ -163,14 +159,13 @@ void InsetPreview::metrics(MetricsInfo & mi, Dimension &
dim) const
if (previewState(mi.base.bv)) {
preview_->metrics(mi, dim);
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
-
+
dim.wid = max(dim.wid, 4);
dim.asc = max(dim.asc, 4);
-
+
dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += TEXT_TO_INSET_OFFSET;
- dim_ = dim;
dim.wid += TEXT_TO_INSET_OFFSET;
// insert a one pixel gap
dim.wid += 1;
diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h
index 15380ba..dead804 100644
--- a/src/insets/InsetPreview.h
+++ b/src/insets/InsetPreview.h
@@ -79,12 +79,7 @@ protected:
///
boost::scoped_ptr<RenderPreview> preview_;
- ///
- mutable bool use_preview_;
-private:
- ///
- mutable Dimension dim_;
};
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 0f62732..b94e172 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -315,7 +315,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool
output_active) const
Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
{
- if (use_preview_) {
+ if (previewState(&cur.bv())) {
edit(cur, true);
return this;
}
@@ -524,7 +524,6 @@ void InsetMathHull::drawBackground(PainterInfo & pi, int x,
int y) const
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
{
BufferView const * const bv = pi.base.bv;
- use_preview_ = previewState(bv);
if (type_ == hullRegexp) {
Dimension const dim = dimension(*bv);
@@ -532,7 +531,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y)
const
dim.width() - 2, dim.height() - 2, Color_regexpframe);
}
- if (use_preview_) {
+ if (previewState(bv)) {
Dimension const dim = dimension(*bv);
if (previewTooSmall(dim)) {
// we have an extra frame
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index 6c55a1f..3e7ce99 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -243,8 +243,6 @@ private:
///
boost::scoped_ptr<RenderPreview> preview_;
///
- mutable bool use_preview_;
- ///
DocIterator docit_;
///
typedef std::map<docstring, int> CounterMap;
diff --git a/status.21x b/status.21x
index 8232a3e..918a346 100644
--- a/status.21x
+++ b/status.21x
@@ -98,6 +98,9 @@ What's new
- Fix automatic insertion of longtable captions (bug 9692).
+- Fix crash with preived math shown in two views of the same document
+ (bug 9957).
+
- Fix setting of nested minipage via the dialog (bug 8716).
- Reset cursor language when changing document-wide language (bug 9586).