]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
fix a crash when the inset containing the new word at cursor is deleted
[lyx.git] / src / mathed / MathMacro.cpp
index 9b86cd19657d8f4de462183c04837c41ba0c9cb8..d96dc31b449623fbe62f5cd3352523d6b25f860b 100644 (file)
@@ -30,7 +30,6 @@
 #include "LaTeXFeatures.h"
 #include "LyX.h"
 #include "LyXRC.h"
-#include "Undo.h"
 
 #include "frontends/Painter.h"
 
@@ -165,9 +164,12 @@ bool MathMacro::editMode(BufferView const * bv) const {
                        // look if there is no other macro in edit mode above
                        ++i;
                        for (; i != cur.depth(); ++i) {
-                               MathMacro const * macro = dynamic_cast<MathMacro const *>(&cur[i].inset());
-                               if (macro && macro->displayMode() == DISPLAY_NORMAL)
-                                       return false;
+                               InsetMath * im = cur[i].asInsetMath();
+                               if (im) {
+                                       MathMacro const * macro = im->asMacro();
+                                       if (macro && macro->displayMode() == DISPLAY_NORMAL)
+                                               return false;
+                               }
                        }
 
                        // ok, none found, I am the highest one
@@ -641,7 +643,8 @@ bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
                        inset_cursor.cell().erase(inset_cursor.pos());
                        inset_cursor.cell().insert(inset_cursor.pos(),
                                createInsetMath(unfolded_name, cur.buffer()));
-                       cur.screenUpdateFlags(cur.result().update() | Update::SinglePar);
+                       cur.resetAnchor();
+                       cur.screenUpdateFlags(cur.result().screenUpdate() | Update::SinglePar);
                        return true;
                }
        }