]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Fix crash when running lyx -dbg insets -e ...
[lyx.git] / src / buffer.C
index f92beccb9121c0979f50bd519ef55ada7e3fbaff..53893e39d3924b5aff3e3f9972401d983a921a77 100644 (file)
@@ -298,6 +298,7 @@ ErtComp ert_comp;
 } // anon
 
 
+int unknown_layouts;
 
 // candidate for move to BufferView
 // (at least some parts in the beginning of the func)
@@ -309,6 +310,7 @@ ErtComp ert_comp;
 // Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
 bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
 {
+       unknown_layouts = 0;
 #ifdef NO_LATEX
        ert_comp.contents.erase();
        ert_comp.active = false;
@@ -363,7 +365,19 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
                first_par = par;
 
        paragraph = first_par;
-       
+
+       if (unknown_layouts > 0) {
+               string s = _("Couldn't set the layout for ");
+               if (unknown_layouts == 1) {
+                       s += _("one paragraph");
+               } else {
+                       s += tostr(unknown_layouts);
+                       s += _(" paragraphs");
+               }
+               WriteAlert(_("Textclass Loading Error!"), s,
+                          _("When reading " + fileName()));
+       }       
+
        return the_end_read;
 }
 
@@ -505,6 +519,12 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                                // layout not found
                                // use default layout "Standard" (0)
                                par->layout = 0;
+                               ++unknown_layouts;
+                               string const s = _("Layout had to be changed from\n")
+                                       + layoutname + _(" to ")
+                                       + textclasslist.NameOfLayout(params.textclass, par->layout);
+                               InsetError * new_inset = new InsetError(s);
+                               par->insertInset(0, new_inset);
                        }
                        // Test whether the layout is obsolete.
                        LyXLayout const & layout =