On Thu, Aug 11, 2016 at 06:19:46PM -0400, Scott Kostyshak wrote:
> On Wed, Aug 10, 2016 at 05:42:45PM -0400, Richard Heck wrote:

> > Probably just a warning.
> 
> Just one warning or one for each? I think a total of one is best, and
> say in the warning that there may be others.

Attached is a patch. Any comments?

Scott
From 7e9d4b021239afb7ccc9a6d0c63fe090b0094d30 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <[email protected]>
Date: Tue, 16 Aug 2016 22:09:57 -0400
Subject: [PATCH] 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 | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index b925496..9d58512 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,7 @@ void latexParagraphs(Buffer const & buf,
        bool already_title = false;
        DocumentClass const & tclass = bparams.documentClass();
 
+       bool gave_layout_warning = false;
        for (; pit < runparams.par_end; ++pit) {
                lastpit = pit;
                ParagraphList::const_iterator par = 
paragraphs.constIterator(pit);
@@ -1189,10 +1193,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) {
-- 
2.7.4

Attachment: signature.asc
Description: PGP signature

Reply via email to