#include "support/lstrings.h"
#include "support/lyxalgo.h"
#include "support/TempFile.h"
+#include "support/unique_ptr.h"
#include "frontends/alert.h"
#include "frontends/Clipboard.h"
#include "frontends/Selection.h"
-#include <boost/tuple/tuple.hpp>
-
#include <string>
+#include <tuple>
using namespace std;
using namespace lyx::support;
// set the paragraphs to plain layout if necessary
DocumentClassConstPtr newDocClass = buffer.params().documentClassPtr();
if (cur.inset().usePlainLayout()) {
- bool forcePlainLayout = cur.inset().forcePlainLayout();
+ bool forcePlainLayout = target_inset->forcePlainLayout();
Layout const & plainLayout = newDocClass->plainLayout();
Layout const & defaultLayout = newDocClass->defaultLayout();
ParagraphList::iterator const end = insertion.end();
// to be so, but the alternative is to construct a new one of these (with a
// new temporary directory, etc) every time, and then to destroy it. So maybe
// it's worth just keeping this one around.
- // FIXME THREAD
static TempFile tempfile("clipboard.internal");
tempfile.setAutoRemove(false);
- static Buffer * staticbuffer = theBufferList().newInternalBuffer(
- tempfile.name().absFileName());
-
- // These two things only really need doing the first time.
- staticbuffer->setUnnamed(true);
- staticbuffer->inset().setBuffer(*staticbuffer);
-
+ // The initialization of staticbuffer is thread-safe. Using a lambda
+ // guarantees that the properties are set only once.
+ static Buffer * staticbuffer = [&](){
+ Buffer * b =
+ theBufferList().newInternalBuffer(tempfile.name().absFileName());
+ b->setUnnamed(true);
+ b->inset().setBuffer(*b);
+ //initialize staticbuffer with b
+ return b;
+ }();
// Use a clone for the complicated stuff so that we do not need to clean
// up in order to avoid a crash.
Buffer * buffer = staticbuffer->cloneBufferOnly();
if (added_one || newlayouts.find(name) != newlayouts.end()) {
// Warn the user.
docstring const s = bformat(_("Layout `%1$s' was not found."), name);
- errorlist.push_back(
- ErrorItem(_("Layout Not Found"), s, it->id(), 0, it->size()));
+ errorlist.push_back(ErrorItem(_("Layout Not Found"), s,
+ {it->id(), 0}, {it->id(), -1}));
}
if (in.usePlainLayout())
layoutName, oldname, newname);
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(
- _("Undefined flex inset"),
- s, it.paragraph().id(), it.pos(), it.pos() + 1));
+ _("Undefined flex inset"), s,
+ {it.paragraph().id(), it.pos()},
+ {it.paragraph().id(), it.pos()+1}));
} else if (code == TABULAR_CODE) {
// The recursion above does not catch paragraphs in "hidden" cells,
// i.e., ones that are part of a multirow or multicolum. So we need
if (begpit != endpit)
cur.screenUpdateFlags(Update::Force | Update::FitCursor);
- boost::tie(endpit, endpos) =
- eraseSelectionHelper(bp,
- text->paragraphs(),
- begpit, endpit,
- cur.selBegin().pos(), endpos);
+ tie(endpit, endpos) =
+ eraseSelectionHelper(bp, text->paragraphs(), begpit, endpit,
+ cur.selBegin().pos(), endpos);
// cutSelection can invalidate the cursor so we need to set
// it anew. (Lgb)
if (sel_index >= theCuts.size())
return docstring();
- boost::scoped_ptr<Buffer> buffer(copyToTempBuffer(theCuts[sel_index].first, docclass));
+ unique_ptr<Buffer> buffer(copyToTempBuffer(theCuts[sel_index].first,
+ docclass));
if (!buffer)
return docstring();
cur.text()->insertStringAsParagraphs(cur, text, cur.current_font);
else
cur.text()->insertStringAsLines(cur, text, cur.current_font);
+ cur.forceBufferUpdate();
return true;
}