]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
Real fix from Bernhard Roider
[lyx.git] / src / lyx_main.C
index 1deaa8ca251cef5ab784c43b0bf8b3f3cb6093dc..97f71100ff10ece894cf3e99837d70daf1cdbd23 100644 (file)
@@ -53,6 +53,7 @@
 #include "support/filetools.h"
 #include "support/lyxlib.h"
 #include "support/convert.h"
+#include "support/ExceptionMessage.h"
 #include "support/os.h"
 #include "support/package.h"
 #include "support/path.h"
@@ -197,7 +198,7 @@ struct LyX::Singletons
 frontend::Application * theApp()
 {
        if (singleton_)
-               return &singleton_->application();
+               return singleton_->pimpl_->application_.get();
        else
                return 0;
 }
@@ -395,9 +396,17 @@ int LyX::exec(int & argc, char * argv[])
        // we need to parse for "-dbg" and "-help"
        easyParse(argc, argv);
 
-       support::init_package(to_utf8(from_local8bit(argv[0])),
+       try { support::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) {
+                       Alert::error(message.title_, message.details_);
+                       exit(1);
+               } else if (message.type_ == support::WarningException) {
+                       Alert::warning(message.title_, message.details_);
+               }
+       }
 
        if (!use_gui) {
                // FIXME: create a ConsoleApplication
@@ -1313,7 +1322,8 @@ int parse_version(string const &, string const &)
 int parse_sysdir(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing directory for -sysdir switch")) << endl;
+               Alert::error(_("No system directory"),
+                       _("Missing directory for -sysdir switch"));
                exit(1);
        }
        cl_system_support = arg;
@@ -1323,7 +1333,8 @@ int parse_sysdir(string const & arg, string const &)
 int parse_userdir(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing directory for -userdir switch")) << endl;
+               Alert::error(_("No user directory"),
+                       _("Missing directory for -userdir switch"));
                exit(1);
        }
        cl_user_support = arg;
@@ -1333,7 +1344,8 @@ int parse_userdir(string const & arg, string const &)
 int parse_execute(string const & arg, string const &)
 {
        if (arg.empty()) {
-               lyxerr << to_utf8(_("Missing command string after --execute switch")) << endl;
+               Alert::error(_("Incomplete command"),
+                       _("Missing command string after --execute switch"));
                exit(1);
        }
        batch = arg;