commit ebd4e25588f61c7f566be6d7800b9e6c4bbcdeb1
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Thu Sep 20 22:15:12 2018 +0200

    Avoid crash with cursor down in math
    
    This can happen when the inset that contains the cursor is outside of
    the screen.
    
    THis is only a workaround. The real solution would be a
    processUpdateFlags(FitCursor) call, but the code is not ready for that
    yet.
    
    Fixes bug #11296.
    
    (cherry picked from commit 17576fb83b5a560fb8a1c59ca7051dcb2b165c05)
---
 src/mathed/InsetMathGrid.cpp |   10 +++++++++-
 status.23x                   |    2 ++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 9c3bd58..71bcf84 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -22,6 +22,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "CoordCache.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
 #include "FuncRequest.h"
@@ -969,7 +970,14 @@ bool InsetMathGrid::idxUpDown(Cursor & cur, bool up) const
                LASSERT(cur.idx() > 0, return false);
                --cur.idx();
        }
-       cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target() - 
cur.cell().xo(cur.bv()));
+       // FIXME: this is only a workaround to avoid a crash if the inset
+       // in not in coord cache. The best would be to force a FitCursor
+       // operation.
+       CoordCache::Arrays const & arraysCache = cur.bv().coordCache().arrays();
+       if (arraysCache.has(&cur.cell()))
+               cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target() - 
cur.cell().xo(cur.bv()));
+       else
+               cur.pos() = 0;
        return true;
 }
 
diff --git a/status.23x b/status.23x
index 65735fe..d2e9291 100644
--- a/status.23x
+++ b/status.23x
@@ -108,6 +108,8 @@ What's new
 
 - Ignore horizontal wheel scrolling in work area (bug 11257).
 
+- Avoid crash wne cursor is outside of workarea (bug 11296).
+
 
 
 * USER INTERFACE

Reply via email to