commit 02e82157ec583c3900e359de86be79fac6512387
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Mon Dec 5 11:51:18 2016 +0100

    Get rid of Inset::setPosCache
    
    This helper method is used to set the inset position cache at drawing
    time. However this is already done by the drawing code itself
    (MathRow::draw, RowPainter::paintInset), so that there is no need to
    do this same work again in a different place.
    
    Note that the inset positions are still set in InsetTabular::draw for
    each cell.
    
    This commit comes with a mild risk attached (it might be that some of
    these calls were useful after all!), but all of this is fixable.
---
 src/insets/Inset.cpp               |    9 ---------
 src/insets/Inset.h                 |    2 --
 src/insets/InsetIPA.cpp            |    1 -
 src/insets/InsetPreview.cpp        |    1 -
 src/mathed/CommandInset.cpp        |    1 -
 src/mathed/InsetMathArray.cpp      |    1 -
 src/mathed/InsetMathBig.cpp        |    1 -
 src/mathed/InsetMathBox.cpp        |    2 --
 src/mathed/InsetMathCases.cpp      |    1 -
 src/mathed/InsetMathColor.cpp      |    1 -
 src/mathed/InsetMathDecoration.cpp |    1 -
 src/mathed/InsetMathDelim.cpp      |    1 -
 src/mathed/InsetMathDiagram.cpp    |    1 -
 src/mathed/InsetMathDots.cpp       |    1 -
 src/mathed/InsetMathFont.cpp       |    1 -
 src/mathed/InsetMathFrac.cpp       |    1 -
 src/mathed/InsetMathHull.cpp       |    2 --
 src/mathed/InsetMathNest.cpp       |    3 +--
 src/mathed/InsetMathSplit.cpp      |    1 -
 src/mathed/InsetMathXYMatrix.cpp   |    1 -
 src/mathed/MathMacro.cpp           |    1 -
 src/mathed/MathMacroArgument.cpp   |    1 -
 src/mathed/MathMacroTemplate.cpp   |    1 -
 23 files changed, 1 insertions(+), 35 deletions(-)

diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 09a45e4..c00f27e 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -549,7 +549,6 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y) 
const
        pi.pain.line(t, d - 3, t, d, pen_color);
        pi.pain.line(x, d, x + 3, d, pen_color);
        pi.pain.line(t - 3, d, t, d, pen_color);
-       setPosCache(pi, x, y);
 }
 
 
@@ -566,7 +565,6 @@ void Inset::drawMarkers2(PainterInfo & pi, int x, int y) 
const
        pi.pain.line(t, a + 3, t, a, pen_color);
        pi.pain.line(x, a, x + 3, a, pen_color);
        pi.pain.line(t - 3, a, t, a, pen_color);
-       setPosCache(pi, x, y);
 }
 
 
@@ -627,13 +625,6 @@ ColorCode Inset::labelColor() const
 }
 
 
-void Inset::setPosCache(PainterInfo const & pi, int x, int y) const
-{
-       //LYXERR("Inset: set position cache to " << x << " " << y);
-       pi.base.bv->coordCache().insets().add(this, x, y);
-}
-
-
 void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
 {
        mi.base.bv->coordCache().insets().add(this, dim);
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index e0418dc..1b3f85e 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -216,8 +216,6 @@ public:
        int xo(BufferView const & bv) const;
        /// last drawn position for 'important' insets
        int yo(BufferView const & bv) const;
-       /// set x/y drawing position cache if available
-       virtual void setPosCache(PainterInfo const &, int, int) const;
        ///
        void setDimCache(MetricsInfo const &, Dimension const &) const;
        /// do we cover screen position x/y?
diff --git a/src/insets/InsetIPA.cpp b/src/insets/InsetIPA.cpp
index 1c20866..a574da8 100644
--- a/src/insets/InsetIPA.cpp
+++ b/src/insets/InsetIPA.cpp
@@ -152,7 +152,6 @@ void InsetIPA::draw(PainterInfo & pi, int x, int y) const
 {
        if (previewState(pi.base.bv)) {
                preview_->draw(pi, x, y);
-               setPosCache(pi, x, y);
                return;
        }
        InsetText::draw(pi, x, y);
diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp
index 37aec63..739322b 100644
--- a/src/insets/InsetPreview.cpp
+++ b/src/insets/InsetPreview.cpp
@@ -139,7 +139,6 @@ void InsetPreview::draw(PainterInfo & pi, int x, int y) 
const
        if (previewState(pi.base.bv)) {
                // one pixel gap in front
                preview_->draw(pi, x + 1, y);
-               setPosCache(pi, x, y);
        } else
                InsetText::draw(pi, x, y);
 }
diff --git a/src/mathed/CommandInset.cpp b/src/mathed/CommandInset.cpp
index 0cf041c..6b94664 100644
--- a/src/mathed/CommandInset.cpp
+++ b/src/mathed/CommandInset.cpp
@@ -58,7 +58,6 @@ Inset * CommandInset::editXY(Cursor & cur, int /*x*/, int 
/*y*/)
 void CommandInset::draw(PainterInfo & pi, int x, int y) const
 {
        button_.draw(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathArray.cpp b/src/mathed/InsetMathArray.cpp
index eb8676d..eeea831 100644
--- a/src/mathed/InsetMathArray.cpp
+++ b/src/mathed/InsetMathArray.cpp
@@ -82,7 +82,6 @@ void InsetMathArray::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathArray::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
        Changer dummy2 = pi.base.changeEnsureMath();
        Changer dummy = pi.base.changeArray();
        InsetMathGrid::draw(pi, x, y);
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index ff3765a..76efc57 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -90,7 +90,6 @@ void InsetMathBig::draw(PainterInfo & pi, int x, int y) const
                (delim_ == "\\\\") ? from_ascii("\\") : support::ltrim(delim_, 
"\\");
        mathed_draw_deco(pi, x + 1, y - dim.ascent(), 4, dim.height(),
                         delim);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index d0ac82f..aff3fb6 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -146,7 +146,6 @@ void InsetMathFBox::draw(PainterInfo & pi, int x, int y) 
const
                dim.width() - 2, dim.height() - 2, Color_foreground);
        Changer dummy = pi.base.changeFontSet("textnormal");
        cell(0).draw(pi, x + 3, y);
-       setPosCache(pi, x, y);
 }
 
 
@@ -370,7 +369,6 @@ void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) 
const
        pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
                dim.width() - 2, dim.height() - 2, Color_foreground);
        cell(0).draw(pi, x + 3, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathCases.cpp b/src/mathed/InsetMathCases.cpp
index 4a7b151..0a5fa33 100644
--- a/src/mathed/InsetMathCases.cpp
+++ b/src/mathed/InsetMathCases.cpp
@@ -56,7 +56,6 @@ void InsetMathCases::draw(PainterInfo & pi, int x, int y) 
const
        Dimension const dim = dimension(*pi.base.bv);
        mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), 
from_ascii("{"));
        InsetMathGrid::draw(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathColor.cpp b/src/mathed/InsetMathColor.cpp
index 966fe5e..ea4f4ef 100644
--- a/src/mathed/InsetMathColor.cpp
+++ b/src/mathed/InsetMathColor.cpp
@@ -60,7 +60,6 @@ void InsetMathColor::draw(PainterInfo & pi, int x, int y) 
const
        cell(0).draw(pi, x + 1, y);
        pi.base.font.setColor(origcol);
        drawMarkers(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index 7a0cfb0..f7fd6ea 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -142,7 +142,6 @@ void InsetMathDecoration::draw(PainterInfo & pi, int x, int 
y) const
                mathed_draw_deco(pi, x + 1 + (dim0.wid - dw_) / 2,
                        y + dy_, dw_, dh_, key_->name);
        drawMarkers(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index d2b284f..e039e64 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -131,7 +131,6 @@ void InsetMathDelim::draw(PainterInfo & pi, int x, int y) 
const
        mathed_draw_deco(pi, x, b, dw_, dim.height(), left_);
        mathed_draw_deco(pi, x + dim.width() - dw_,
                b, dw_, dim.height(), right_);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathDiagram.cpp b/src/mathed/InsetMathDiagram.cpp
index 6b12949..c2019d4 100644
--- a/src/mathed/InsetMathDiagram.cpp
+++ b/src/mathed/InsetMathDiagram.cpp
@@ -58,7 +58,6 @@ void InsetMathDiagram::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathDiagram::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
        Changer dummy2 = pi.base.changeEnsureMath();
        FontInfo & f = pi.base.font;
        Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp
index b579964..8c4bd83 100644
--- a/src/mathed/InsetMathDots.cpp
+++ b/src/mathed/InsetMathDots.cpp
@@ -69,7 +69,6 @@ void InsetMathDots::draw(PainterInfo & pi, int x, int y) const
                --y;
        mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
                key_->name);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp
index 825cf33..05f9e66 100644
--- a/src/mathed/InsetMathFont.cpp
+++ b/src/mathed/InsetMathFont.cpp
@@ -95,7 +95,6 @@ void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
        Changer dummy = pi.base.changeFontSet(font());
        cell(0).draw(pi, x + 1, y);
        drawMarkers(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 2362495..ad999a2 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -275,7 +275,6 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
        Changer dummy3 = pi.base.changeEnsureMath();
        Dimension const dim = dimension(*pi.base.bv);
        Dimension const dim0 = cell(0).dimension(*pi.base.bv);
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 52442b2..4027707 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -609,7 +609,6 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
                        // one pixel gap in front
                        preview_->draw(pi, x + 1, y);
                }
-               setPosCache(pi, x, y);
                return;
        }
 
@@ -637,7 +636,6 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
        if (canPaintChange(*bv))
                pi.change_.paintCue(pi, x + 1, y + 1 - dim.asc,
                                    x + dim.wid, y + dim.des);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 3794a58..ecd8230 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -265,14 +265,13 @@ void InsetMathNest::dump() const
 }
 
 
-void InsetMathNest::draw(PainterInfo & pi, int x, int y) const
+void InsetMathNest::draw(PainterInfo &, int, int) const
 {
 #if 0
        if (lock_)
                pi.pain.fillRectangle(x, y - ascent(), width(), height(),
                                        Color_mathlockbg);
 #endif
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathSplit.cpp b/src/mathed/InsetMathSplit.cpp
index 5008a8d..c260e2e 100644
--- a/src/mathed/InsetMathSplit.cpp
+++ b/src/mathed/InsetMathSplit.cpp
@@ -106,7 +106,6 @@ void InsetMathSplit::draw(PainterInfo & pi, int x, int y) 
const
 {
        Changer dummy = pi.base.changeEnsureMath();
        InsetMathGrid::draw(pi, x, y);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathXYMatrix.cpp b/src/mathed/InsetMathXYMatrix.cpp
index ab5cb83..0994914 100644
--- a/src/mathed/InsetMathXYMatrix.cpp
+++ b/src/mathed/InsetMathXYMatrix.cpp
@@ -57,7 +57,6 @@ void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathXYMatrix::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
        Changer dummy2 = pi.base.changeEnsureMath();
        Changer dummy = pi.base.changeArray();
        InsetMathGrid::draw(pi, x, y);
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 71654b4..6a5c904 100644
--- a/src/mathed/MathMacro.cpp
+++ b/src/mathed/MathMacro.cpp
@@ -624,7 +624,6 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
 {
        Dimension const dim = dimension(*pi.base.bv);
 
-       setPosCache(pi, x, y);
        int expx = x;
        int expy = y;
 
diff --git a/src/mathed/MathMacroArgument.cpp b/src/mathed/MathMacroArgument.cpp
index 2e6b0e2..76b43f3 100644
--- a/src/mathed/MathMacroArgument.cpp
+++ b/src/mathed/MathMacroArgument.cpp
@@ -69,7 +69,6 @@ void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & 
dim) const
 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
 {
        drawStrRed(pi, x, y, str_);
-       setPosCache(pi, x, y);
 }
 
 
diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp
index 42d8177..2a7dc77 100644
--- a/src/mathed/MathMacroTemplate.cpp
+++ b/src/mathed/MathMacroTemplate.cpp
@@ -590,7 +590,6 @@ void MathMacroTemplate::draw(PainterInfo & pi, int x, int 
y) const
        Changer dummy1 = pi.base.changeFontSet("mathnormal");
        Changer dummy2 = pi.base.font.changeStyle(LM_ST_TEXT);
 
-       setPosCache(pi, x, y);
        Dimension const dim = dimension(*pi.base.bv);
 
        // draw outer frame

Reply via email to