From 7a15d8b2324c2e88db6fcb87656094338316674c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 24 Sep 2011 20:53:28 +0000 Subject: [PATCH] Do not change, even if temporarily, the environment of the main process 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 | 25 +++++++++++-------------- src/support/SystemcallPrivate.h | 2 -- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 741feb2338..47f5e73cd2 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -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; diff --git a/src/support/SystemcallPrivate.h b/src/support/SystemcallPrivate.h index ee8aeb164c..c0a4c7755a 100644 --- a/src/support/SystemcallPrivate.h +++ b/src/support/SystemcallPrivate.h @@ -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; -- 2.39.2