[LyX/master] More places where DocumentClassPtr should not be copied

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sat Sep 14 18:41:28 UTC 2024


commit 928f9514a890edf37e298e419104a98c4ebfe844
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sat Sep 14 20:40:53 2024 +0200

    More places where DocumentClassPtr should not be copied
    
    Spotted by COverity scan.
---
 src/CutAndPaste.cpp | 10 +++++-----
 src/CutAndPaste.h   |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 951c65a87f..3de2a92a73 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -126,7 +126,7 @@ static bool isFullyDeleted(ParagraphList const & pars)
 
 PasteReturnValue
 pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
-                     DocumentClassConstPtr oldDocClass, cap::BranchAction branchAction,
+                     DocumentClassConstPtr const & oldDocClass, cap::BranchAction branchAction,
                      ErrorList & errorlist)
 {
 	Buffer const & buffer = *cur.buffer();
@@ -229,7 +229,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
 	}
 
 	// set the paragraphs to plain layout if necessary
-	DocumentClassConstPtr newDocClass = buffer.params().documentClassPtr();
+	DocumentClassConstPtr const & newDocClass = buffer.params().documentClassPtr();
 	Layout const & plainLayout = newDocClass->plainLayout();
 	Layout const & defaultLayout = newDocClass->defaultLayout();
 	if (cur.inset().usePlainLayout()) {
@@ -699,7 +699,7 @@ void putClipboard(ParagraphList const & paragraphs,
 
 void copySelectionHelper(Buffer const & buf, Text const & text,
 	pit_type startpit, pit_type endpit,
-	int start, int end, DocumentClassConstPtr dc, CutStack & cutstack)
+	int start, int end, DocumentClassConstPtr const & dc, CutStack & cutstack)
 {
 	ParagraphList const & pars = text.paragraphs();
 
@@ -1245,14 +1245,14 @@ docstring selection(size_t sel_index, DocInfoPair docinfo, bool for_math)
 
 
 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
-			DocumentClassConstPtr docclass, AuthorList const & authors,
+			DocumentClassConstPtr const & docclass, AuthorList const & authors,
 			ErrorList & errorList,
 			cap::BranchAction branchAction)
 {
 	// Copy authors to the params. We need those pointers.
 	for (Author const & a : authors)
 		cur.buffer()->params().authors().record(a);
-	
+
 	if (cur.inTexted()) {
 		Text * text = cur.text();
 		LBUFERR(text);
diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h
index 1b1c2f684d..0692afe596 100644
--- a/src/CutAndPaste.h
+++ b/src/CutAndPaste.h
@@ -128,7 +128,7 @@ enum BranchAction {
 /// Paste the paragraph list \p parlist at the position given by \p cur.
 /// Does not handle undo. Does only work in text, not mathed.
 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
-			DocumentClassConstPtr textclass, AuthorList const & authors,
+			DocumentClassConstPtr const & textclass, AuthorList const & authors,
 			ErrorList & errorList,
 			BranchAction branchAction = BRANCH_ASK);
 


More information about the lyx-cvs mailing list