From: Enrico Forestieri Date: Thu, 12 Apr 2012 14:25:38 +0000 (+0200) Subject: Fix bug #8105: Crash when deleting math macro from the inside X-Git-Tag: 2.1.0beta1~1933^2~42 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d07f9eec20c8709b648a494586d4b03f75cfef47;p=lyx.git Fix bug #8105: Crash when deleting math macro from the inside It seems that parameterless macros are not wrapped into a MathAtom. Rather than touching the macro code (which is tantamount to opening a can of worms, IMHO), I prefer this solution. --- diff --git a/src/CursorSlice.cpp b/src/CursorSlice.cpp index c4b1c72f80..b4352e3ba4 100644 --- a/src/CursorSlice.cpp +++ b/src/CursorSlice.cpp @@ -23,7 +23,7 @@ #include "insets/Inset.h" #include "mathed/InsetMath.h" -#include "mathed/MathData.h" +#include "mathed/MathMacro.h" #include "support/lassert.h" @@ -61,8 +61,10 @@ Paragraph & CursorSlice::paragraph() const pos_type CursorSlice::lastpos() const { LASSERT(inset_, /**/); - return inset_->asInsetMath() ? cell().size() - : (text()->empty() ? 0 : paragraph().size()); + InsetMath const * math = inset_->asInsetMath(); + bool paramless_macro = math && math->asMacro() && !math->asMacro()->nargs(); + return math ? (paramless_macro ? 0 : cell().size()) + : (text()->empty() ? 0 : paragraph().size()); }