]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
* lyx_gui: create_view(), start() and exit() functions deleted.
[lyx.git] / src / lyx_main.C
index 100d845f539d69cb086fbcdae591c742aac89611..18e7453ff59822ca544788440489110e0e74565c 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "buffer.h"
 #include "buffer_funcs.h"
+#include "bufferlist.h"
 #include "converter.h"
 #include "debug.h"
 #include "encoding.h"
@@ -33,6 +34,7 @@
 #include "lyxfunc.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
+#include "lyxserver.h"
 #include "lyxtextclasslist.h"
 #include "MenuBackend.h"
 #include "mover.h"
@@ -45,6 +47,7 @@
 
 #include "support/environment.h"
 #include "support/filetools.h"
+#include "support/fontutils.h"
 #include "support/lyxlib.h"
 #include "support/convert.h"
 #include "support/os.h"
@@ -105,9 +108,12 @@ void lyx_exit(int status)
        // FIXME: We should not directly call exit(), since it only
        // guarantees a return to the system, no application cleanup.
        // This may cause troubles with not executed destructors.
-       if (lyx_gui::use_gui)
-               // lyx_gui::exit may return and only schedule the exit
-               lyx_gui::exit(status);
+       if (lyx_gui::use_gui) {
+               theApp->exit(status);
+               // Restore original font resources after Application is destroyed.
+               lyx::support::restoreFontResources();
+       }
+
        exit(status);
 }
 
@@ -214,8 +220,11 @@ int LyX::priv_exec(int & argc, char * argv[])
                                   lyx::support::top_build_dir_is_one_level_up);
 
        // Start the real execution loop.
-       if (lyx_gui::use_gui)
+       if (lyx_gui::use_gui) {
+               // Force adding of font path _before_ Application is initialized
+               lyx::support::addFontResources();
                return lyx_gui::exec(argc, argv);
+       }
        else
                return exec2(argc, argv);
 }
@@ -335,7 +344,8 @@ int LyX::exec2(int & argc, char * argv[])
                        height = 0;
                }
                // create the main window
-               LyXView * view = lyx_gui::create_view(width, height, posx, posy, maximize);
+               LyXView * view = &theApp->createView(width, height, posx, posy, maximize);
+               ref().addLyXView(view);
 
                // load files
                for_each(files.begin(), files.end(),
@@ -353,7 +363,7 @@ int LyX::exec2(int & argc, char * argv[])
                // clear this list to save a few bytes of RAM
                session_->clearLastOpenedFiles();
 
-               return lyx_gui::start(view, batch_command);
+               return theApp->start(batch_command);
        } else {
                // Something went wrong above
                quitLyX(false);