]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
Correct tex2lyx/roundtrip/test-structure.tex test.
[lyx.git] / src / LyX.cpp
index c3d84b22f614d2c636cd18a1990313d679e15386..d81c90f6ff95c8061a785162e9b8ec79f44d6c2f 100644 (file)
@@ -404,10 +404,8 @@ void LyX::prepareExit()
                        LYXERR(Debug::INFO, "Deleting tmp dir "
                                << package().temp_dir().absFileName());
                        if (!package().temp_dir().destroyDirectory()) {
-                               docstring const msg =
-                                       bformat(_("Unable to remove the temporary directory %1$s"),
-                                       from_utf8(package().temp_dir().absFileName()));
-                               Alert::warning(_("Unable to remove temporary directory"), msg);
+                               LYXERR0(bformat(_("Unable to remove the temporary directory %1$s"),
+                                       from_utf8(package().temp_dir().absFileName())));
                        }
                }
        }
@@ -783,33 +781,35 @@ void cleanDuplicateEnvVars()
 static void initTemplatePath()
 {
        FileName const package_template_path =
-               FileName(addPath(package().system_support().absFileName(), "templates"));
+               FileName(addName(package().system_support().absFileName(), "templates"));
 
        if (lyxrc.template_path.empty()) {
                lyxrc.template_path = package_template_path.absFileName();
        }
 #if defined (USE_MACOSX_PACKAGING)
        FileName const user_template_path =
-               FileName(addPath(package().user_support().absFileName(), "templates"));
+               FileName(addName(package().user_support().absFileName(), "templates"));
 
        if (package_template_path != FileName(lyxrc.template_path) &&
                user_template_path != FileName(lyxrc.template_path))
        {
                return;
        }
-       /// addPath cannot be used here.
-       /// The path with trailing slash doesn't work as symlink name.
        FileName const user_template_link =
-               FileName(user_template_path.absFileName() + "SystemTemplates");
-       if (user_template_link.isSymLink()) {
+               FileName(addName(user_template_path.absFileName(),"SystemTemplates"));
+       if (user_template_link.isSymLink() && !equivalent(user_template_link, package_template_path)) {
                user_template_link.removeFile();
        }
        if (!user_template_link.exists()) {
                if (!package_template_path.link(user_template_link)) {
-                       LYXERR(Debug::INIT, "Cannot create symlink " + user_template_link.absFileName());
-                       lyxrc.template_path = package_template_path.absFileName();
+                       FileName const user_support = package().user_support();
+                       if (user_support.exists() && user_support.isDirectory()) {
+                               LYXERR(Debug::INIT, "Cannot create symlink " + user_template_link.absFileName());
+                               lyxrc.template_path = package_template_path.absFileName();
+                       }
                        return;
                }
+               LYXERR(Debug::INIT, "Symlink \"" << user_template_link.absFileName() << "\" created.");
        }
        lyxrc.template_path = user_template_path.absFileName();
 #endif
@@ -883,6 +883,8 @@ bool LyX::init()
 
                if (queryUserLyXDir(package().explicit_user_support())) {
                        package().reconfigureUserLyXDir("");
+                       // Now the user directory is present on first start.
+                       initTemplatePath();
                }
                fileUnlock(fd, lock_file.c_str());
        }
@@ -1386,7 +1388,7 @@ FuncStatus getStatus(FuncRequest const & action)
 }
 
 
-void dispatch(FuncRequest const & action)
+DispatchResult const & dispatch(FuncRequest const & action)
 {
        LAPPERR(theApp());
        return theApp()->dispatch(action);
@@ -1396,7 +1398,7 @@ void dispatch(FuncRequest const & action)
 void dispatch(FuncRequest const & action, DispatchResult & dr)
 {
        LAPPERR(theApp());
-       return theApp()->dispatch(action, dr);
+       theApp()->dispatch(action, dr);
 }