From: Scott Kostyshak Date: Wed, 17 Aug 2016 02:09:57 +0000 (-0400) Subject: Warn in GUI when mixing Title and InTitle layouts X-Git-Tag: 2.2.2~57 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=deec55866c1deff9585ab4e69d7a9e5aa5f7e45a;p=features.git 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 (cherry picked from commit 0b1cf1330d850b21313f5e68a83bb5053e52e6ec) --- diff --git a/src/output_latex.cpp b/src/output_latex.cpp index c5079beb30..6de0e811a5 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -28,12 +28,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 @@ -1177,6 +1180,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); @@ -1188,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) {