X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=1bee03276b0cbdcc92230e6eb622e8a2825fff28;hb=0362c6aae73c293d1c20277c12d362acfe0b2ef6;hp=8584d46bee315878c954f674400b76bc12366f3a;hpb=b89cc942eb458284f40f4d4e7db58890c3288979;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index 8584d46bee..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" @@ -93,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()); @@ -310,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());