]> git.lyx.org Git - features.git/commitdiff
Fix bug 1323
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 14 Oct 2003 12:49:15 +0000 (12:49 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 14 Oct 2003 12:49:15 +0000 (12:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7918 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/factory.C
src/paragraph_funcs.C

index 13cc7b1b07a6488ee6179f890224060c8ecd9383..d97f9b4f974cb78c7e10b093ebe58f22738d618d 100644 (file)
@@ -1,3 +1,12 @@
+2003-10-14  Alfredo Braunstein  <abraunst@libero.it>
+
+       * paragraph_funcs.C (readParToken): report unknown insets as error
+       boxes. Use the outer paragraph as location (also for unknown
+       tokens).
+
+       * factory.C (readInset): do not abort on reading an unknown inset. 
+       Eat it and return 0.
+
 2003-10-13  Angus Leeming  <leeming@lyx.org>
 
        * lyx_main.C (LyX): remove call to setDisplayTranslator().
index 6c728827d22d15f5a48cbb4e86bab3b36165ec48..ca58000af54c65e7988f53692ea9fbf1d4cb71e2 100644 (file)
@@ -366,8 +366,11 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                } else if (cmdName == "printindex") {
                        inset = new InsetPrintIndex(inscmd);
                } else {
-                       lyxerr << "unknown CommandInset '" << cmdName << "'" << std::endl;
-                       BOOST_ASSERT(false);
+                       lyxerr << "unknown CommandInset '" << cmdName
+                              << "'" << std::endl;
+                       while (lex.isOK() && lex.getString() != "\\end_inset")
+                               lex.next();
+                       return 0;
                }
        } else {
                if (tmptok == "Quotes") {
@@ -430,8 +433,11 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                } else if (tmptok == "FloatList") {
                        inset = new InsetFloatList;
                } else {
-                       lyxerr << "unknown Inset type '" << tmptok << "'" << std::endl;
-                       BOOST_ASSERT(false);
+                       lyxerr << "unknown Inset type '" << tmptok
+                              << "'" << std::endl;
+                       while (lex.isOK() && lex.getString() != "\\end_inset")
+                               lex.next();
+                       return 0;
                }
 
                inset->read(buf, lex);
index 91bca9935817ba83568024db2d3051a5a562e956..2d2d61aa9a4e8e9c99b6d83d97cc5d775251580b 100644 (file)
@@ -865,7 +865,16 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                       << "Missing \\begin_inset?.\n";
        } else if (token == "\\begin_inset") {
                InsetOld * inset = readInset(lex, buf);
-               par.insertInset(par.size(), inset, font, change);
+               if (inset)
+                       par.insertInset(par.size(), inset, font, change);
+               else {
+                       lex.eatLine();
+                       string line = lex.getString();
+                       buf.error(ErrorItem(_("Unknown Inset"), line,
+                                           buf.paragraphs().back().id(),
+                                           0, par.size()));
+                       return 1;
+               }
        } else if (token == "\\family") {
                lex.next();
                font.setLyXFamily(lex.getString());
@@ -986,7 +995,8 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                        token, lex.getString());
 
                buf.error(ErrorItem(_("Unknown token"), s,
-                                   par.id(), 0, par.size()));
+                                   buf.paragraphs().back().id(),
+                                   0, par.size()));
                return 1;
        }
        return 0;