From cb3044101e4e2c44755768ddb471e3c3d0a1d2b4 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 1 Jun 2010 13:34:31 +0000 Subject: [PATCH] Fix bug #6739: Loading in a 1.6.5 file causes 1.6.6-1 to crash git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@34580 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/MathData.cpp | 29 ++++++++++++++++++----------- status.16x | 3 +++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index c7f8544eb0..00f02c896f 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -614,7 +614,7 @@ void MathData::attachMacroParameters(Cursor * cur, size_t p = macroPos + 1; vector detachedArgs; MathAtom scriptToPutAround; - + // find cursor slice again of this MathData int thisSlice = -1; if (cur) @@ -622,7 +622,7 @@ void MathData::attachMacroParameters(Cursor * cur, int thisPos = -1; if (thisSlice != -1) thisPos = (*cur)[thisSlice].pos(); - + // find arguments behind the macro if (!interactiveInit) { collectOptionalParameters(cur, macroOptionals, detachedArgs, p, @@ -630,27 +630,34 @@ void MathData::attachMacroParameters(Cursor * cur, } collectParameters(cur, macroNumArgs, detachedArgs, p, scriptToPutAround, macroPos, thisPos, thisSlice, appetite); - + // attach arguments back to macro inset macroInset->attachArguments(detachedArgs, macroNumArgs, macroOptionals); - + // found tail script? E.g. \foo{a}b^x if (scriptToPutAround.nucleus()) { + InsetMathScript * scriptInset = + scriptToPutAround.nucleus()->asScriptInset(); + // In the math parser we remove empty braces in the base + // of a script inset, but we have to restore them here. + if (scriptInset->nuc().empty()) { + MathData ar; + scriptInset->nuc().push_back( + MathAtom(new InsetMathBrace(ar))); + } // put macro into a script inset - scriptToPutAround.nucleus()->asScriptInset()->nuc()[0] - = operator[](macroPos); + scriptInset->nuc()[0] = operator[](macroPos); operator[](macroPos) = scriptToPutAround; // go into the script inset nucleus if (cur && thisPos == int(macroPos)) cur->append(0, 0); - + // get pointer to "deep" copied macro inset - InsetMathScript * scriptInset - = operator[](macroPos).nucleus()->asScriptInset(); + scriptInset = operator[](macroPos).nucleus()->asScriptInset(); macroInset = scriptInset->nuc()[0].nucleus()->asMacro(); } - + // remove them from the MathData erase(begin() + macroPos + 1, begin() + p); @@ -661,7 +668,7 @@ void MathData::attachMacroParameters(Cursor * cur, // fix cursor if right of p if (thisPos >= int(p)) (*cur)[thisSlice].pos() -= p - (macroPos + 1); - + // was the macro inset just inserted interactively and was now folded // and the cursor is just behind? if ((*cur)[thisSlice].pos() == int(macroPos + 1) diff --git a/status.16x b/status.16x index 467ea56426..44285a537d 100644 --- a/status.16x +++ b/status.16x @@ -92,6 +92,9 @@ What's new - Allow to overwrite files without dialog popup on export from GUI (bug 2844). +- Fix assertion when using an empty user macro taking an argument as + the base of script inset (bug 6739). + * USER INTERFACE