#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"
#include <iostream>
#include <csignal>
#include <map>
+#include <stdlib.h>
#include <string>
#include <vector>
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;
}
+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_);
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_);
}
}
// 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", allow_unreadable));
}
if (first_start)
#else
if (err_sig == SIGSEGV || !getEnv("LYXDEBUG").empty())
#endif
- support::abort();
+ abort();
exit(0);
}
break;
}
case ui_menuset:
- menubackend.read(lex);
+ theApp()->menuBackend().read(lex);
break;
case ui_toolbarset: