commit a69bae0c99e1d365b1fe59693274ba7f608e1829
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Feb 24 23:58:53 2017 +0100
Make InsetMathNest::editXY more robust
If no reasonable cell has been found to put the cursor in (maybe
because the cell exist but is not in the cache), exit gracefully.
Fixes bug #10520
---
src/mathed/InsetMathNest.cpp | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 1f0adda..596e32a 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -1495,7 +1495,7 @@ void InsetMathNest::edit(Cursor & cur, bool front,
EntryDirection entry_from)
Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
{
- int idx_min = 0;
+ int idx_min = -1;
int dist_min = 1000000;
for (idx_type i = 0, n = nargs(); i != n; ++i) {
int const d = cell(i).dist(cur.bv(), x, y);
@@ -1504,6 +1504,9 @@ Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
idx_min = i;
}
}
+ if (idx_min == -1)
+ return this;
+
MathData & ar = cell(idx_min);
cur.push(*this);
cur.idx() = idx_min;