From c75522bbb7a0044f2370ced294a27738d47935ea Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 29 Jun 2022 22:52:16 +0200 Subject: [PATCH] Fix crash when dissolving a top level math inset This should be disabled not only for math hull, but also macro template. Fixes bug #12562. --- src/mathed/InsetMathNest.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index cfa5aaf076..05920cc1e4 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1275,13 +1275,16 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) cur.undispatched(); break; } - case LFUN_INSET_DISSOLVE: - if (!asHullInset()) { + case LFUN_INSET_DISSOLVE: { + bool const enabled = cur.inMathed() + && (&cur.inset() != this || cur[cur.depth() - 1].inset().inMathed()); + if (enabled) { cur.recordUndoInset(); + // FIXME: this loses data cur.pullArg(); } break; - + } case LFUN_MATH_LIMITS: { InsetMath * in = 0; if (cur.pos() < cur.lastpos() && cur.nextMath().allowsLimitsChange()) @@ -1497,10 +1500,13 @@ bool InsetMathNest::getStatus(Cursor & cur, FuncRequest const & cmd, break; } - case LFUN_INSET_DISSOLVE: - flag.setEnabled(!asHullInset()); + case LFUN_INSET_DISSOLVE: { + // Do not dissolve a math inset which is in text + bool const enabled = cur.inMathed() + && (&cur.inset() != this || cur[cur.depth() - 1].inset().inMathed()); + flag.setEnabled(enabled); break; - + } case LFUN_PASTE: { docstring const & name = cmd.argument(); if (name == "html" || name == "latex") -- 2.39.5