From 0eedbdee03dd697a5f6bccd0438fd3947da740b0 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 14 Jun 2011 18:06:57 +0000 Subject: [PATCH] Don't rely on Qt for setting an environment variable. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39049 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/Systemcall.cpp | 23 ++++++++++++----------- src/support/SystemcallPrivate.h | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 0753c590c8..e4fa5b2559 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -268,6 +268,7 @@ 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()) { @@ -290,18 +291,15 @@ void SystemcallPrivate::startProcess(QString const & cmd, string const & path) cmd_ = cmd; if (process_) { if (!path.empty() && !lyxrc.texinputs_prefix.empty()) { - QString const texinputs = toqstr(os::latex_path_list( - replaceCurdirPath(path, lyxrc.texinputs_prefix))); - QChar const sep = os::path_separator(os::TEXENGINE); - QString const prefix = QLatin1String("TEXINPUTS=.") - + sep + texinputs + sep; - QStringList env = QProcess::systemEnvironment(); - if (env.filter("TEXINPUTS=").isEmpty()) - env << prefix; + string const texinputs = 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(); else - env.replaceInStrings(QRegExp("^TEXINPUTS=(.*)"), - prefix + "\\1"); - process_->setEnvironment(env); + setEnv("TEXINPUTS", prefix + texinputs_); } state = SystemcallPrivate::Starting; process_->start(cmd_); @@ -361,6 +359,9 @@ 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 c0a4c7755a..ee8aeb164c 100644 --- a/src/support/SystemcallPrivate.h +++ b/src/support/SystemcallPrivate.h @@ -74,6 +74,8 @@ 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