]> git.lyx.org Git - features.git/commitdiff
Don't rely on Qt for setting an environment variable.
authorEnrico Forestieri <forenr@lyx.org>
Tue, 14 Jun 2011 18:06:57 +0000 (18:06 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 14 Jun 2011 18:06:57 +0000 (18:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39049 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 0753c590c8c0b5fe3b0454a6a5c2e1c9aa5a4f18..e4fa5b255992354620cd786a5eb76a25293fec4e 100644 (file)
@@ -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;
index c0a4c7755a66c016b902ff4bec941f178a23a235..ee8aeb164cb9f964632b75ce970c70d74882ff04 100644 (file)
@@ -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;