]> git.lyx.org Git - features.git/commitdiff
Do not change, even if temporarily, the environment of the main process
authorEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2011 20:53:28 +0000 (20:53 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2011 20:53:28 +0000 (20:53 +0000)
but only that of the launched QProcess.
This will help changing the code in order to manage in a central place
the LaTeX environment, thus avoiding the current code duplication in
Systemcall and ForkedCalls.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39754 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/Systemcall.cpp
src/support/SystemcallPrivate.h

index 741feb233843834c95a596e06e2f361edfea39f7..47f5e73cd20d58f457a113eaa4cb810b7898e9d6 100644 (file)
@@ -268,7 +268,6 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) :
                                 out_index_(0),
                                 err_index_(0),
                                 out_file_(of), 
-                                texinputs_(getEnv("TEXINPUTS")),
                                 process_events_(false)
 {
        if (!out_file_.empty()) {
@@ -285,27 +284,28 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) :
 }
 
 
-
 void SystemcallPrivate::startProcess(QString const & cmd, string const & path)
 {
        cmd_ = cmd;
        if (process_) {
+               string cmd_prefix;
                if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
-                       string const texinputs = os::latex_path_list(
+                       string const texinputs_prefix = os::latex_path_list(
                                replaceCurdirPath(path, lyxrc.texinputs_prefix));
                        string const sep = string(1,
                                        os::path_separator(os::TEXENGINE));
-                       string const prefix = "." + sep + texinputs + sep;
-                       if (prefixIs(texinputs_, prefix))
-                               texinputs_.clear();
+                       string const env = getEnv("TEXINPUTS");
+                       string const texinputs = "." + sep + texinputs_prefix
+                                                    + sep + env;
+                       if (os::shell() == os::UNIX)
+                               cmd_prefix = "env 'TEXINPUTS="
+                                               + texinputs + "' ";
                        else
-                               setEnv("TEXINPUTS", prefix + texinputs_);
+                               cmd_prefix = "cmd /d /c set TEXINPUTS="
+                                               + texinputs + " & ";
                }
                state = SystemcallPrivate::Starting;
-               if (os::shell() == os::CMD_EXE)
-                       process_->start(QLatin1String("cmd /d /c ") + cmd_);
-               else
-                       process_->start(cmd_);
+               process_->start(toqstr(cmd_prefix) + cmd_);
        }
 }
 
@@ -362,9 +362,6 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
 
 SystemcallPrivate::~SystemcallPrivate()
 {
-       if (!texinputs_.empty())
-               setEnv("TEXINPUTS", texinputs_);
-
        if (out_index_) {
                out_data_[out_index_] = '\0';
                out_index_ = 0;
index ee8aeb164cb9f964632b75ce970c70d74882ff04..c0a4c7755a66c016b902ff4bec941f178a23a235 100644 (file)
@@ -74,8 +74,6 @@ private:
        size_t err_index_;
        ///
        std::string out_file_;
-       ///
-       std::string texinputs_;
 
        /// Size of buffers.
        static size_t const buffer_size_ = 200;