From 75e3b6a419af7f51a921ecc6fffa8fc194a4c253 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 21 Aug 2007 08:17:07 +0000 Subject: [PATCH] Fix crash when using down cursor in an empty math subscript (Bug 4117). http://bugzilla.lyx.org/show_bug.cgi?id=4117 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19689 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Cursor.cpp | 4 +++- src/Cursor.h | 5 +++-- src/mathed/InsetMathNest.cpp | 12 ++++++++++-- status.15x | 2 ++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index bb9b91dec6..463a4edbb1 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1482,12 +1482,14 @@ Font Cursor::getFont() const } -void Cursor::fixIfBroken() +bool Cursor::fixIfBroken() { if (DocIterator::fixIfBroken()) { clearSelection(); resetAnchor(); + return true; } + return false; } diff --git a/src/Cursor.h b/src/Cursor.h index cf2344f2c6..c56538a2df 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -179,8 +179,9 @@ public: * Not using noUpdate() should never be wrong. */ void noUpdate(); - /// fix cursor in circumstances that should never happen - void fixIfBroken(); + /// fix cursor in circumstances that should never happen. + /// \retval true if a fix occured. + bool fixIfBroken(); /// output friend std::ostream & operator<<(std::ostream & os, Cursor const & cur); diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 8a7db60910..5aeada99f9 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -568,8 +568,16 @@ goto_char_backwards: // notify left insets and give them chance to set update flags lyx::notifyCursorLeaves(cur.beforeDispatchCursor(), cur); cur.fixIfBroken(); - } else - cur.undispatched(); + break; + } + + if (cur.fixIfBroken()) + // FIXME: Something bad happened. We pass the corrected Cursor + // instead of letting things go worse. + break; + + // We did not manage to move the cursor. + cur.undispatched(); break; } diff --git a/status.15x b/status.15x index bab7e22222..a495340c2e 100644 --- a/status.15x +++ b/status.15x @@ -76,6 +76,8 @@ What's new - Fix crash when a user removes a formula when its preview is being generated. (gcc 3 only). +- Fix crash when using down cursor in an empty math subscript (Bug 4117). + * DOCUMENTATION - Embedded Objects manual: section about longtable alignment added