commit 946d112ee6b5a8b341f81d5954f2d45dbb185268
Author: Richard Kimberly Heck <[email protected]>
Date: Thu Feb 25 21:49:50 2021 -0500
Allow to call cap::switchBetweenClasses without an ErrorList.
It turns out that we usually don't care about the errors and so
were creating dummy ErrorList objects in several places.
---
src/Buffer.cpp | 6 ++----
src/Compare.cpp | 3 +--
src/CutAndPaste.cpp | 7 +++++++
src/CutAndPaste.h | 8 ++++++--
src/Undo.cpp | 4 +---
src/frontends/qt/GuiApplication.cpp | 3 +--
6 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 5c7b886..d87578d 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -627,10 +627,9 @@ void Buffer::cloneWithChildren(BufferMap & bufmap,
CloneList_ptr clones) const
// The clone needs its own DocumentClass, since running updateBuffer()
will
// modify it, and we would otherwise be sharing it with the original
Buffer.
buffer_clone->params().makeDocumentClass(true);
- ErrorList el;
cap::switchBetweenClasses(
params().documentClassPtr(),
buffer_clone->params().documentClassPtr(),
- static_cast<InsetText &>(buffer_clone->inset()), el);
+ static_cast<InsetText &>(buffer_clone->inset()));
bufmap[this] = buffer_clone;
clones->insert(buffer_clone);
@@ -672,10 +671,9 @@ Buffer * Buffer::cloneBufferOnly() const {
// The clone needs its own DocumentClass, since running updateBuffer()
will
// modify it, and we would otherwise be sharing it with the original
Buffer.
buffer_clone->params().makeDocumentClass(true);
- ErrorList el;
cap::switchBetweenClasses(
params().documentClassPtr(),
buffer_clone->params().documentClassPtr(),
- static_cast<InsetText &>(buffer_clone->inset()), el);
+ static_cast<InsetText &>(buffer_clone->inset()));
clones->insert(buffer_clone);
buffer_clone->d->clone_list_ = clones;
diff --git a/src/Compare.cpp b/src/Compare.cpp
index 7d90891..17bd012 100644
--- a/src/Compare.cpp
+++ b/src/Compare.cpp
@@ -407,10 +407,9 @@ void Compare::run()
// new buffer with the document class from wherever they came from.
// So we need to reset the document class of all the paragraphs.
// See bug #10295.
- ErrorList el;
cap::switchBetweenClasses(
olddc, dest_buffer->params().documentClassPtr(),
- static_cast<InsetText &>(dest_buffer->inset()), el);
+ static_cast<InsetText &>(dest_buffer->inset()));
finished(pimpl_->abort_);
}
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 150fd8a..6ab73f4 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -798,6 +798,13 @@ bool multipleCellsSelected(CursorData const & cur)
void switchBetweenClasses(DocumentClassConstPtr oldone,
+ DocumentClassConstPtr newone, InsetText & in) {
+ ErrorList el = {};
+ switchBetweenClasses(oldone, newone, in, el);
+}
+
+
+void switchBetweenClasses(DocumentClassConstPtr oldone,
DocumentClassConstPtr newone, InsetText & in, ErrorList &
errorlist)
{
errorlist.clear();
diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h
index e4ff08b..6640332 100644
--- a/src/CutAndPaste.h
+++ b/src/CutAndPaste.h
@@ -133,10 +133,14 @@ void pasteParagraphList(Cursor & cur, ParagraphList const
& parlist,
/** Needed to switch between different classes. This works
* for a list of paragraphs beginning with the specified par.
- * It changes layouts and character styles.
+ * It changes layouts and character styles. Errors are reported
+ * in the passed ErrorList.
*/
void switchBetweenClasses(DocumentClassConstPtr oldone,
- DocumentClassConstPtr newone, InsetText & in, ErrorList
&);
+ DocumentClassConstPtr newone, InsetText & in, ErrorList & el);
+/// Same but without error reporting.
+void switchBetweenClasses(DocumentClassConstPtr oldone,
+ DocumentClassConstPtr newone, InsetText & in);
/// Get the current selection as a string. Does not change the selection.
/// Does only work if the whole selection is in mathed.
diff --git a/src/Undo.cpp b/src/Undo.cpp
index e7c84f5..a870241 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -450,10 +450,8 @@ void Undo::Private::doUndoRedoAction(CursorData & cur,
UndoElementStack & stack,
otherstack.top().bparams = new BufferParams(buffer_.params());
DocumentClassConstPtr olddc =
buffer_.params().documentClassPtr();
buffer_.params() = *undo.bparams;
- // The error list is not supposed to be helpful here.
- ErrorList el;
cap::switchBetweenClasses(olddc,
buffer_.params().documentClassPtr(),
- static_cast<InsetText &>(buffer_.inset()), el);
+ static_cast<InsetText &>(buffer_.inset()));
} else if (dit.inMathed()) {
// We stored the full cell here as there is not much to be
// gained by storing just 'a few' paragraphs (most if not
diff --git a/src/frontends/qt/GuiApplication.cpp
b/src/frontends/qt/GuiApplication.cpp
index fc2210a..2296a52 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -2164,9 +2164,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd,
DispatchResult & dr)
DocumentClassConstPtr olddc =
defaults.params().documentClassPtr();
int const unknown_tokens = defaults.readHeader(lex);
DocumentClassConstPtr newdc =
defaults.params().documentClassPtr();
- ErrorList el;
InsetText & theinset = static_cast<InsetText
&>(defaults.inset());
- cap::switchBetweenClasses(olddc, newdc, theinset, el);
+ cap::switchBetweenClasses(olddc, newdc, theinset);
if (unknown_tokens != 0) {
lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs