]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
Tweaks.
[lyx.git] / src / LyX.cpp
index a5c5093cde701486742d7e8eb5eb49351b6e48dc..e12d859f403e796f4e330e8a5ff3c0443a65ec60 100644 (file)
@@ -52,7 +52,6 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 #include "support/Messages.h"
 #include "support/os.h"
 #include "support/Package.h"
@@ -66,6 +65,7 @@
 #include <iostream>
 #include <csignal>
 #include <map>
+#include <stdlib.h>
 #include <string>
 #include <vector>
 
@@ -185,6 +185,26 @@ LyX::~LyX()
 }
 
 
+void LyX::exit(int exit_code) const
+{
+       if (exit_code)
+               // Something wrong happened so better save everything, just in
+               // case.
+               emergencyCleanup();
+
+#ifndef NDEBUG
+       // Properly crash in debug mode in order to get a useful backtrace.
+       abort();
+#endif
+
+       // In release mode, try to exit gracefully.
+       if (theApp())
+               theApp()->exit(exit_code);
+       else
+               exit(exit_code);
+}
+
+
 LyX & LyX::ref()
 {
        BOOST_ASSERT(singleton_);
@@ -510,7 +530,7 @@ int LyX::init(int & argc, char * argv[])
                // the filename if necessary
                pimpl_->files_to_load_.push_back(fileSearch(string(),
                        os::internal_path(to_utf8(from_local8bit(argv[argi]))),
-                       "lyx", allow_unreadable));
+                       "lyx", may_not_exist));
        }
 
        if (first_start)
@@ -729,7 +749,7 @@ static void error_handler(int err_sig)
 #else
        if (err_sig == SIGSEGV || !getEnv("LYXDEBUG").empty())
 #endif
-               support::abort();
+               abort();
        exit(0);
 }
 
@@ -1089,7 +1109,7 @@ bool LyX::readUIFile(string const & name, bool include)
                        break;
                }
                case ui_menuset:
-                       menubackend.read(lex);
+                       theApp()->menuBackend().read(lex);
                        break;
 
                case ui_toolbarset: