]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
Tweaks.
[lyx.git] / src / LyX.cpp
index 1d13df399b104bf3def3b34cacb9f0868b01c21a..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>
 
@@ -110,7 +110,7 @@ void reconfigureUserLyXDir()
        string const configure_command = package().configure_command();
 
        lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
-       support::PathChanger p(package().user_support());
+       PathChanger p(package().user_support());
        Systemcall one;
        one.startscript(Systemcall::Wait, configure_command);
        lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
@@ -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_);
@@ -351,14 +371,14 @@ int LyX::exec(int & argc, char * argv[])
        easyParse(argc, argv);
 
        try {
-               support::init_package(to_utf8(from_local8bit(argv[0])),
+               init_package(to_utf8(from_local8bit(argv[0])),
                              cl_system_support, cl_user_support,
-                             support::top_build_dir_is_one_level_up);
-       } catch (support::ExceptionMessage const & message) {
-               if (message.type_ == support::ErrorException) {
+                             top_build_dir_is_one_level_up);
+       } catch (ExceptionMessage const & message) {
+               if (message.type_ == ErrorException) {
                        Alert::error(message.title_, message.details_);
                        exit(1);
-               } else if (message.type_ == support::WarningException) {
+               } else if (message.type_ == WarningException) {
                        Alert::warning(message.title_, message.details_);
                }
        }
@@ -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", support::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: