Author: forenr
Date: Tue Jun 1 15:34:31 2010
New Revision: 34580
URL: http://www.lyx.org/trac/changeset/34580
Log:
Fix bug #6739: Loading in a 1.6.5 file causes 1.6.6-1 to crash
Modified:
lyx-devel/branches/BRANCH_1_6_X/src/mathed/MathData.cpp
lyx-devel/branches/BRANCH_1_6_X/status.16x
Modified: lyx-devel/branches/BRANCH_1_6_X/src/mathed/MathData.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/mathed/MathData.cpp Tue Jun 1
15:32:10 2010 (r34579)
+++ lyx-devel/branches/BRANCH_1_6_X/src/mathed/MathData.cpp Tue Jun 1
15:34:31 2010 (r34580)
@@ -614,7 +614,7 @@
size_t p = macroPos + 1;
vector<MathData> detachedArgs;
MathAtom scriptToPutAround;
-
+
// find cursor slice again of this MathData
int thisSlice = -1;
if (cur)
@@ -622,7 +622,7 @@
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 @@
}
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 @@
// 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)
Modified: lyx-devel/branches/BRANCH_1_6_X/status.16x
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/status.16x Tue Jun 1 15:32:10 2010
(r34579)
+++ lyx-devel/branches/BRANCH_1_6_X/status.16x Tue Jun 1 15:34:31 2010
(r34580)
@@ -92,6 +92,9 @@
- 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