X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=1bee03276b0cbdcc92230e6eb622e8a2825fff28;hb=1acedf11da79f509da706bc8d6d2f491c9676087;hp=c33d64f21fe7113998cc2261d3c1e0326b507a92;hpb=ac08e89095af413817b08b538a4ed8cb0eabbfdd;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index c33d64f21f..1bee03276b 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -22,6 +22,7 @@ #include "frontends/alert.h" +#include "support/ExceptionMessage.h" #include "support/debug.h" #include "support/filetools.h" #include "support/gettext.h" @@ -35,29 +36,11 @@ using boost::bind; -using std::auto_ptr; -using std::endl; -using std::equal_to; -using std::find; -using std::find_if; -using std::for_each; -using std::string; -using std::vector; -using std::back_inserter; -using std::transform; - +using namespace std; +using namespace lyx::support; namespace lyx { -using support::addName; -using support::bformat; -using support::FileName; -using support::makeDisplayPath; -using support::onlyFilename; -using support::removeAutosaveFile; -using support::package; -using support::prefixIs; - namespace Alert = lyx::frontend::Alert; @@ -111,7 +94,17 @@ void BufferList::release(Buffer * buf) Buffer * BufferList::newBuffer(string const & s, bool const ronly) { - auto_ptr tmpbuf(new Buffer(s, ronly)); + auto_ptr tmpbuf; + try { tmpbuf.reset(new Buffer(s, ronly)); + } 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; + } + } tmpbuf->params().useClassDefaults(); LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size()); bstore.push_back(tmpbuf.get()); @@ -328,11 +321,11 @@ void BufferList::setCurrentAuthor(docstring const & name, docstring const & emai } -int BufferList::bufferNum(std::string const & name) const +int BufferList::bufferNum(string const & name) const { vector buffers = getFileNames(); vector::const_iterator cit = - std::find(buffers.begin(), buffers.end(), name); + find(buffers.begin(), buffers.end(), name); if (cit == buffers.end()) return 0; return int(cit - buffers.begin());