X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FBufferList.cpp;h=d69438846f5a7f22591b66b57dcf34e1eb4eee56;hb=48d9d01a826eb9f1c1e7c62edb664ec97f6a6e8d;hp=fe8caf8c1fd67489246f56afdcb1b97798661251;hpb=79787c22748540b231e2a56684b90e5c878fdc3a;p=features.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index fe8caf8c1f..d69438846f 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -15,10 +15,7 @@ #include "Author.h" #include "Buffer.h" #include "BufferParams.h" -#include "Session.h" -#include "LyX.h" -#include "output_latex.h" -#include "ParagraphList.h" +#include "OutputParams.h" #include "frontends/alert.h" @@ -27,13 +24,12 @@ #include "support/FileName.h" #include "support/FileNameList.h" #include "support/filetools.h" -#include "support/gettext.h" #include "support/lstrings.h" -#include "support/Package.h" #include "support/lassert.h" #include +#include // exit() #include #include @@ -133,14 +129,14 @@ Buffer * BufferList::createNewBuffer(string const & s) { unique_ptr tmpbuf; try { - tmpbuf = make_unique(s); + tmpbuf = lyx::make_unique(s); } catch (ExceptionMessage const & message) { if (message.type_ == ErrorException) { Alert::error(message.title_, message.details_); exit(1); } else if (message.type_ == WarningException) { Alert::warning(message.title_, message.details_); - return 0; + return nullptr; } } tmpbuf->params().useClassDefaults(); @@ -167,7 +163,7 @@ FileNameList BufferList::fileNames() const Buffer * BufferList::first() { if (bstore.empty()) - return 0; + return nullptr; return bstore.front(); } @@ -175,7 +171,7 @@ Buffer * BufferList::first() Buffer * BufferList::last() { if (bstore.empty()) - return 0; + return nullptr; return bstore.back(); } @@ -183,7 +179,7 @@ Buffer * BufferList::last() Buffer * BufferList::getBuffer(unsigned int choice) { if (choice >= bstore.size()) - return 0; + return nullptr; return bstore[choice]; } @@ -191,13 +187,13 @@ Buffer * BufferList::getBuffer(unsigned int choice) Buffer * BufferList::next(Buffer const * buf) const { // Something is wrong, but we can probably survive it. - LASSERT(buf, return 0); + LASSERT(buf, return nullptr); if (bstore.empty()) - return 0; + return nullptr; BufferStorage::const_iterator it = find(bstore.begin(), bstore.end(), buf); - LASSERT(it != bstore.end(), return 0); + LASSERT(it != bstore.end(), return nullptr); ++it; Buffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it; return nextbuf; @@ -207,13 +203,13 @@ Buffer * BufferList::next(Buffer const * buf) const Buffer * BufferList::previous(Buffer const * buf) const { // Something is wrong, but we can probably survive it. - LASSERT(buf, return 0); + LASSERT(buf, return nullptr); if (bstore.empty()) - return 0; + return nullptr; BufferStorage::const_iterator it = find(bstore.begin(), bstore.end(), buf); - LASSERT(it != bstore.end(), return 0); + LASSERT(it != bstore.end(), return nullptr); Buffer * previousbuf = (it == bstore.begin()) ? bstore.back() : *(it - 1); return previousbuf; @@ -252,7 +248,7 @@ void BufferList::invalidateConverterCache() const bool BufferList::exists(FileName const & fname) const { - return getBuffer(fname) != 0; + return getBuffer(fname) != nullptr; } @@ -314,29 +310,30 @@ Buffer * BufferList::getBuffer(support::FileName const & fname, bool internal) c if (equivalent(b->fileName(), fname)) return b; } - return 0; + return nullptr; } -Buffer * BufferList::getBufferFromTmp(string const & s) +Buffer * BufferList::getBufferFromTmp(string const & path, bool realpath) { for (Buffer * buf : bstore) { - if (prefixIs(s, buf->temppath())) { + string const temppath = realpath ? FileName(buf->temppath()).realPath() : buf->temppath(); + if (prefixIs(path, temppath)) { // check whether the filename matches the master string const master_name = buf->latexName(); - if (suffixIs(s, master_name)) + if (suffixIs(path, master_name)) return buf; // if not, try with the children for (Buffer * child : buf->getDescendants()) { string const mangled_child_name = DocFileName( changeExtension(child->absFileName(), ".tex")).mangledFileName(); - if (suffixIs(s, mangled_child_name)) + if (suffixIs(path, mangled_child_name)) return child; } } } - return 0; + return nullptr; }