commit 0b1cf1330d850b21313f5e68a83bb5053e52e6ec
Author: Scott Kostyshak <[email protected]>
Date:   Tue Aug 16 22:09:57 2016 -0400

    Warn in GUI when mixing Title and InTitle layouts
    
    Since we process layouts sequentially, we export LaTeX code for the
    title once we arrive to a layout that has InTitle false. If the
    document then later has a layout with InTitle true, we do not
    (currently) go back to add it to the title and just output it
    in-place. We previously warned with LYXERR0, but since this can
    cause missing or unexpected output we now warn in the GUI.
    
    For more information, see the following lyx-devel thread:
    
https://www.mail-archive.com/search?l=mid&q=a65ae226-d3bd-8fc5-a93b-7bb23f1cda82%40lyx.org
---
 src/output_latex.cpp |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index b925496..f5c6a10 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -29,12 +29,15 @@
 #include "insets/InsetBibitem.h"
 #include "insets/InsetArgument.h"
 
+#include "frontends/alert.h"
+
 #include "support/lassert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
 #include "support/textutils.h"
+#include "support/gettext.h"
 
 #include <QThreadStorage>
 
@@ -1178,6 +1181,8 @@ void latexParagraphs(Buffer const & buf,
        bool already_title = false;
        DocumentClass const & tclass = bparams.documentClass();
 
+       // Did we already warn about inTitle layout mixing? (we only warn once)
+       bool gave_layout_warning = false;
        for (; pit < runparams.par_end; ++pit) {
                lastpit = pit;
                ParagraphList::const_iterator par = 
paragraphs.constIterator(pit);
@@ -1189,10 +1194,15 @@ void latexParagraphs(Buffer const & buf,
 
                if (layout.intitle) {
                        if (already_title) {
-                               LYXERR0("Error in latexParagraphs: You"
-                                       " are using a layout (\"" << 
layout.name() << "\")"
-                                       " intended for the title, after using"
-                                       " non-title layouts.");
+                               if (!gave_layout_warning) {
+                                       gave_layout_warning = true;
+                                       frontend::Alert::warning(_("Error in 
latexParagraphs"),
+                                                       bformat(_("You are 
using at least one "
+                                                         "layout (%1$s) 
intended for the title, "
+                                                         "after using 
non-title layouts. This "
+                                                         "could lead to 
missing or incorrect output."
+                                                         ), layout.name()));
+                               }
                        } else if (!was_title) {
                                was_title = true;
                                if (tclass.titletype() == TITLE_ENVIRONMENT) {

Reply via email to