On Fri, Apr 13, 2018 at 03:53:28PM +0000, Juergen Spitzmueller wrote:

> +bool InsetText::needsCProtection() const
> +{
> +     if (!getLayout().needsCProtect())
> +             return false;
> +
> +     // Environments need cprotection regardless the content
> +     if (getLayout().latextype() == InsetLayout::ENVIRONMENT)
> +             return true;

What is the !getLayout().needsCProtect() check for? Does it need to go
before the environment check, or is the attached patch OK?

Scott
From 4554a76ac3edf79b9c04c3a1791ac48a79c533d9 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Sun, 22 Apr 2018 13:10:26 -0400
Subject: [PATCH] Fix cprotection of environments in commands

Commands that contain any environment should be cprotected. This
check should be done before the check for
getLayout().needsCProtect().

This commit fixes compilation of, e.g., boxes and floats in section
titles.
---
 src/insets/InsetText.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index b38a1dc..ce00da7 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -1093,14 +1093,14 @@ bool InsetText::needsCProtection() const
 	if (hasCProtectContent())
 		return true;
 
-	if (!getLayout().needsCProtect())
-		return false;
-
 	// Environments and "no latex" types (e.g., knitr chunks)
 	// need cprotection regardless the content
 	if (getLayout().latextype() != InsetLayout::COMMAND)
 		return true;
 
+	if (!getLayout().needsCProtect())
+		return false;
+
 	// Commands need cprotection if they contain specific chars
 	int const nchars_escape = 9;
 	static char_type const chars_escape[nchars_escape] = {
-- 
2.7.4

Attachment: signature.asc
Description: PGP signature

Reply via email to