]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
Update cursor and scrollbar after resize.
[lyx.git] / src / BufferList.cpp
index c33d64f21fe7113998cc2261d3c1e0326b507a92..1bee03276b0cbdcc92230e6eb622e8a2825fff28 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "frontends/alert.h"
 
+#include "support/ExceptionMessage.h"
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
 
 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<Buffer> tmpbuf(new Buffer(s, ronly));
+       auto_ptr<Buffer> 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<string> buffers = getFileNames();
        vector<string>::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());