[LyX/2.5.x] Amend 2d2d22682

Juergen Spitzmueller <[email protected]> Sat, 25 Apr 2026 11:11:02 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit b42a04e25eab54f160d4e667de78b72113abcd47
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Apr 25 13:04:56 2026 +0200

    Amend 2d2d22682
    
    map is sorted, which we do not want here
    
    (cherry picked from commit 3c01ce65c4daec7e5faad2e97c304a2c1257c518)
---
 src/LaTeXFeatures.cpp | 23 ++++++++++++++++++-----
 src/LaTeXFeatures.h   |  2 +-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 72b3e79dc7..e541d46c44 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -702,8 +702,21 @@ void LaTeXFeatures::useLayout(docstring const & layoutname, int level)
 			thm.style = layout.thmStyle();
 			thm.zrefname = layout.thmZRefName();
 			thm.refprefix = to_ascii(layout.refprefix);
-			usedTheorems_[thm.name] = thm;
-			require("amsthm");
+			// check if this theorem has already
+			// been defined. If so, overwrite the
+			// existing definition
+			bool thm_exists = false;
+			for (auto & av_thm : usedTheorems_) {
+				if (av_thm.name == thm.name) {
+					av_thm = thm;
+					thm_exists = true;
+					break;
+				}
+			}
+			if (!thm_exists) {
+				usedTheorems_.push_back(thm);
+				require("amsthm");
+			}
 		}
 		usedLayouts_.push_back(layoutname);
 	} else {
@@ -2010,8 +2023,8 @@ string const LaTeXFeatures::getThmDefinitions() const
 	ostringstream tmp;
 
 	string laststyle;
-	for (auto const & [name, thm] : usedTheorems_) {
-		if (isProvided("newtheorem:" + name))
+	for (auto const & thm : usedTheorems_) {
+		if (isProvided("newtheorem:" + thm.name))
 			continue;
 		if (thm.style != laststyle) {
 			tmp << "\\theoremstyle{" << thm.style << "}\n";
@@ -2042,7 +2055,7 @@ string const LaTeXFeatures::getThmExtraDefinitions() const
 {
 	ostringstream tmp;
 
-	for (auto const & [name, thm] : usedTheorems_) {
+	for (auto const & thm : usedTheorems_) {
 		if (thm.counter == "none")
 			continue;
 
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index 5ccc014f3b..f420c3286a 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -249,7 +249,7 @@ private:
 	///
 	UsedFloats usedFloats_;
 	///
-	std::map<std::string, ThmInfo> usedTheorems_;
+	std::list<ThmInfo> usedTheorems_;
 	///
 	typedef std::map<docstring, std::string> FileMap;
 	///
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs