]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
Point fix, earlier forgotten
[lyx.git] / src / lyx_main.C
index 0a5ee65ceecc6dbb23f707e233f634656c0c53e6..dc59f8c2113b986cfe850b54a644d9166ea614cd 100644 (file)
@@ -1,9 +1,15 @@
 /**
  * \file lyx_main.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
+ * \author Alfredo Braunstein
  * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
@@ -59,13 +65,10 @@ using std::signal;
 using std::system;
 #endif
 
-extern void LoadLyXFile(string const &);
 extern void QuitLyX();
 
 extern LyXServer * lyxserver;
 
-extern string user_lyxdir;
-
 DebugStream lyxerr;
 
 boost::scoped_ptr<LastFiles> lastfiles;
@@ -99,9 +102,8 @@ LyX::LyX(int & argc, char * argv[])
        // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
        lyx::graphics::setDisplayTranslator();
 
-       if (want_gui) {
+       if (want_gui)
                lyx_gui::parse_init(argc, argv);
-       }
 
        // check for any spurious extra arguments
        // other than documents
@@ -118,15 +120,13 @@ LyX::LyX(int & argc, char * argv[])
        init(want_gui);
        lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
 
-       if (want_gui) {
+       if (want_gui) 
                lyx_gui::parse_lyxrc();
-       }
 
        vector<string> files;
 
-       for (int argi = argc - 1; argi >= 1; --argi) {
+       for (int argi = argc - 1; argi >= 1; --argi) 
                files.push_back(argv[argi]);
-       }
 
        if (first_start)
                files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
@@ -147,14 +147,14 @@ LyX::LyX(int & argc, char * argv[])
                        // the filename if necessary
                        string s = FileSearch(string(), *it, "lyx");
                        if (s.empty()) {
-                               last_loaded = newFile(*it, "");
+                               last_loaded = newFile(*it, string(), true);
                        } else {
-                               last_loaded = bufferlist.newBuffer(s, false);
-                               last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
-                               if (!loadLyXFile(last_loaded, s)) {
-                                       bufferlist.release(last_loaded);
-                                       last_loaded = newFile(*it, string());
-                               }
+                               Buffer * buf = bufferlist.newBuffer(s, false);
+                               buf->error.connect(boost::bind(&LyX::printError, this, _1));
+                               if (loadLyXFile(buf, s)) 
+                                       last_loaded = buf;
+                               else
+                                       bufferlist.release(buf);
                        }
                }
 
@@ -253,7 +253,7 @@ void LyX::init(bool gui)
        }
 
        if (lyxrc.lastfiles.empty()) {
-               lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
+               lyxrc.lastfiles = AddName(user_lyxdir(), "lastfiles");
        }
 
        if (lyxrc.roman_font_name.empty())
@@ -415,16 +415,16 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
        string const configure_script = AddName(system_lyxdir(), "configure");
 
        // Does user directory exist?
-       FileInfo fileInfo(user_lyxdir);
+       FileInfo fileInfo(user_lyxdir());
        if (fileInfo.isOK() && fileInfo.isDir()) {
                first_start = false;
                FileInfo script(configure_script);
-               FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
+               FileInfo defaults(AddName(user_lyxdir(), "lyxrc.defaults"));
                if (defaults.isOK() && script.isOK()
                    && defaults.getModificationTime() < script.getModificationTime()) {
                        lyxerr << _("LyX: reconfiguring user directory")
                               << endl;
-                       Path p(user_lyxdir);
+                       Path p(user_lyxdir());
                        ::system(configure_script.c_str());
                        lyxerr << "LyX: " << _("Done!") << endl;
                }
@@ -434,18 +434,18 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
        first_start = !explicit_userdir;
 
        lyxerr << bformat(_("LyX: Creating directory %1$s"
-                                 " and running configure..."), user_lyxdir) << endl;
+                                 " and running configure..."), user_lyxdir()) << endl;
 
-       if (!createDirectory(user_lyxdir, 0755)) {
+       if (!createDirectory(user_lyxdir(), 0755)) {
                // Failed, let's use $HOME instead.
-               user_lyxdir = GetEnvPath("HOME");
+               user_lyxdir(GetEnvPath("HOME"));
                lyxerr << bformat(_("Failed. Will use %1$s instead."),
-                       user_lyxdir) << endl;
+                       user_lyxdir()) << endl;
                return;
        }
 
        // Run configure in user lyx directory
-       Path p(user_lyxdir);
+       Path p(user_lyxdir());
        ::system(configure_script.c_str());
        lyxerr << "LyX: " << _("Done!") << endl;
 }
@@ -656,7 +656,7 @@ int parse_userdir(string const & arg, string const &)
                lyxerr << _("Missing directory for -userdir switch") << endl;
                exit(1);
        }
-       user_lyxdir = arg;
+       user_lyxdir(arg);
        return 1;
 }