]> git.lyx.org Git - features.git/commitdiff
Fix bug #8105: Crash when deleting math macro from the inside
authorEnrico Forestieri <forenr@lyx.org>
Thu, 12 Apr 2012 14:25:38 +0000 (16:25 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 15 Apr 2012 21:59:18 +0000 (23:59 +0200)
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.

(cherry picked from commit d07f9eec20c8709b648a494586d4b03f75cfef47)

src/CursorSlice.cpp
status.20x

index c4b1c72f80d803868a01b39e226e66cf1cba4841..b4352e3ba4b64976d54448fb9d62bfc33b8dd184 100644 (file)
@@ -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());
 }
 
 
index 70f49ff190b2179b6662f3b4e03137d189b7efe6..b7bd859347a598198b2018e7a6a4306f5fcabf19 100644 (file)
@@ -89,6 +89,9 @@ What's new
   flag by using the same latex backend used for previewing the document
   instead of always using the plain latex backend.
 
+- Fix crash when dissolving a math macro whose first argument is another
+  parameterless macro (bug 8105).
+
 
 * USER INTERFACE