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
This commit is contained in:
Enrico Forestieri 2011-09-24 20:53:28 +00:00
parent d57f507f51
commit 7a15d8b232
2 changed files with 11 additions and 16 deletions

View 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;

View 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;