]> git.lyx.org Git - features.git/commitdiff
Don't rely upon there being a certain number of argumnets to the box inset.
authorRichard Heck <rgheck@comcast.net>
Tue, 6 Jul 2010 14:50:59 +0000 (14:50 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 6 Jul 2010 14:50:59 +0000 (14:50 +0000)
Some later LyX version might omit defaults without lyx2lyx to replace them.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34787 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py

index 2a26029db4c99c0693f31d9b4649e7674f192886..cc0444efcb542d93c47e74ea634d8491d14283fa 100644 (file)
@@ -1830,9 +1830,13 @@ def revert_makebox(document):
       return
     j = find_token(document.body, 'use_makebox 1', i)
     # assure we found the makebox of the current box
-    if j > i + 7 or j == -1:
+    if j > z or j == -1:
       return
-    # remove the \end_inset
+    y = find_token(document.body, "\\begin_layout", i)
+    if y > z or y == -1:
+      document.warning("Malformed LyX document: Can't find layout in box.")
+      return
+    # remove the \end_layout \end_inset pair
     document.body[z - 2:z + 1] = put_cmd_in_ert("}")
     # determine the alignment
     k = find_token(document.body, 'hor_pos', j - 4)
@@ -1846,7 +1850,7 @@ def revert_makebox(document):
     length = latex_length(length).split(",")[1]
     subst = "\\makebox[" + length + "][" \
       + align + "]{"
-    document.body[i:i + 14] = put_cmd_in_ert(subst)
+    document.body[i:y+1] = put_cmd_in_ert(subst)
     i += 1