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
This commit is contained in:
Scott Kostyshak 2016-08-16 22:09:57 -04:00
parent fb46b3a1ee
commit 0b1cf1330d

View File

@ -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) {