X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_main.C;h=aab365784227cdb7de034661181b7bdbde76b7d9;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=cc856fb70a4e3a8aaca7f0a644e1d1af14e227e5;hpb=3815df7705b09920f9bb60c6fd9ee0576fe0a834;p=lyx.git diff --git a/src/lyx_main.C b/src/lyx_main.C index cc856fb70a..aab3657842 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -17,6 +17,7 @@ #include "lyx_main.h" +#include "ConverterCache.h" #include "buffer.h" #include "buffer_funcs.h" #include "bufferlist.h" @@ -56,6 +57,7 @@ #include "support/package.h" #include "support/path.h" #include "support/systemcall.h" +#include "support/unicode.h" #include #include @@ -113,6 +115,7 @@ namespace { string cl_system_support; string cl_user_support; +LyX * singleton_ = 0; void showFileError(string const & error) { @@ -139,6 +142,9 @@ void reconfigureUserLyXDir() /// The main application class private implementation. struct LyX::Singletons { + Singletons(): iconv(ucs4_codeset, "UTF-8") + { + } /// our function handler LyXFunc lyxfunc_; /// @@ -153,41 +159,42 @@ struct LyX::Singletons boost::scoped_ptr application_; /// lyx session, containing lastfiles, lastfilepos, and lastopened boost::scoped_ptr session_; -}; - -boost::scoped_ptr LyX::singleton_; + /// + IconvProcessor iconv; +}; -int LyX::exec(int & argc, char * argv[]) +LyX::~LyX() { - BOOST_ASSERT(!singleton_.get()); - // We must return from this before launching the gui so that - // other parts of the code can access singleton_ through - // LyX::ref and LyX::cref. - singleton_.reset(new LyX); - // Start the real execution loop. - return singleton_->priv_exec(argc, argv); + // Static data are not treated in the same way at all on the Mac (and + // the LyX singleton has static methods). This is the reason why the + // exit command on the Mac bypasses our dispatch machinery altogether. + // On Linux and Windows we won't pass a second time through quit() + // because quitting will already be set to true. + if (!quitting) + quit(); } LyX & LyX::ref() { - BOOST_ASSERT(singleton_.get()); - return *singleton_.get(); + BOOST_ASSERT(singleton_); + return *singleton_; } LyX const & LyX::cref() { - BOOST_ASSERT(singleton_.get()); - return *singleton_.get(); + BOOST_ASSERT(singleton_); + return *singleton_; } LyX::LyX() : first_start(false), geometryOption_(false) { + singleton_ = this; pimpl_.reset(new Singletons); } @@ -279,6 +286,12 @@ kb_keymap & LyX::topLevelKeymap() } +IconvProcessor & LyX::iconvProcessor() +{ + return pimpl_->iconv; +} + + kb_keymap const & LyX::topLevelKeymap() const { BOOST_ASSERT(pimpl_->toplevel_keymap_.get()); @@ -305,7 +318,7 @@ Buffer const * const LyX::updateInset(InsetBase const * inset) const } -int LyX::priv_exec(int & argc, char * argv[]) +int LyX::exec(int & argc, char * argv[]) { // Here we need to parse the command line. At least // we need to parse for "-dbg" and "-help" @@ -796,6 +809,11 @@ bool LyX::init() lyxerr[Debug::INIT] << "Reading session information '.lyx/session'..." << endl; pimpl_->session_.reset(new Session(lyxrc.num_lastfiles)); + + // This must happen after package initialization and after lyxrc is + // read, therefore it can't be done by a static object. + ConverterCache::init(); + return true; } @@ -1305,4 +1323,10 @@ kb_keymap & theTopLevelKeymap() return LyX::ref().topLevelKeymap(); } + +IconvProcessor & utf8ToUcs4() +{ + return LyX::ref().iconvProcessor(); +} + } // namespace lyx