]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
more const correctness
[lyx.git] / src / LyX.cpp
index d2484d152e1f25195eeca966702258200a77744d..66ff6f3dbed227559ab8d99e98aa4ed038bc8a79 100644 (file)
@@ -50,6 +50,7 @@
 #include "frontends/alert.h"
 #include "frontends/Application.h"
 
+#include "support/bind.h"
 #include "support/ConsoleApplication.h"
 #include "support/lassert.h"
 #include "support/debug.h"
@@ -61,9 +62,7 @@
 #include "support/Messages.h"
 #include "support/os.h"
 #include "support/Package.h"
-
-#include "support/bind.h"
-#include <boost/scoped_ptr.hpp>
+#include "support/unique_ptr.h"
 
 #include <algorithm>
 #include <iostream>
@@ -150,13 +149,13 @@ struct LyX::Impl {
        ///
        CmdDef toplevel_cmddef_;
        ///
-       boost::scoped_ptr<Server> lyx_server_;
+       unique_ptr<Server> lyx_server_;
        ///
-       boost::scoped_ptr<ServerSocket> lyx_socket_;
+       unique_ptr<ServerSocket> lyx_socket_;
        ///
-       boost::scoped_ptr<frontend::Application> application_;
+       unique_ptr<frontend::Application> application_;
        /// lyx session, containing lastfiles, lastfilepos, and lastopened
-       boost::scoped_ptr<Session> session_;
+       unique_ptr<Session> session_;
 
        /// Files to load at start.
        vector<string> files_to_load_;
@@ -491,14 +490,15 @@ int LyX::execWithoutGui(int & argc, char * argv[])
 
                Buffer * buf = pimpl_->buffer_list_.newBuffer(fname.absFileName());
                LYXERR(Debug::FILES, "Loading " << fname);
-               if (buf->loadLyXFile() == Buffer::ReadSuccess) {
+               if (buf && buf->loadLyXFile() == Buffer::ReadSuccess) {
                        ErrorList const & el = buf->errorList("Parse");
                        if (!el.empty())
                                        for_each(el.begin(), el.end(),
                                                                         bind(&LyX::printError, this, _1));
                        command_line_buffers.push_back(buf);
                } else {
-                       pimpl_->buffer_list_.release(buf);
+                       if (buf)
+                               pimpl_->buffer_list_.release(buf);
                        docstring const error_message =
                                        bformat(_("LyX failed to load the following file: %1$s"),
                                                                        from_utf8(fname.absFileName()));
@@ -1415,7 +1415,7 @@ Server & theServer()
        // FIXME: this should not be use_gui dependent
        LWARNIF(use_gui);
        LAPPERR(singleton_);
-       return *singleton_->pimpl_->lyx_server_.get();
+       return *singleton_->pimpl_->lyx_server_;
 }
 
 
@@ -1424,7 +1424,7 @@ ServerSocket & theServerSocket()
        // FIXME: this should not be use_gui dependent
        LWARNIF(use_gui);
        LAPPERR(singleton_);
-       return *singleton_->pimpl_->lyx_socket_.get();
+       return *singleton_->pimpl_->lyx_socket_;
 }