]> git.lyx.org Git - features.git/commitdiff
Also set TEXINPUTS when launching ForkedCall processes.
authorEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2011 01:32:35 +0000 (01:32 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 24 Sep 2011 01:32:35 +0000 (01:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39742 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/PreviewLoader.cpp
src/support/ForkedCalls.cpp
src/support/ForkedCalls.h

index feadc45c9e80bb417d46bf0bbfcd2f0ac6b27176..eadcd93f23773fbc9affde294f791d5d5cb4adfe 100644 (file)
@@ -608,7 +608,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
        string const command = libScriptSearch(cs.str());
 
        if (wait) {
-               ForkedCall call;
+               ForkedCall call(buffer_.filePath());
                int ret = call.startScript(ForkedProcess::Wait, command);
                static int fake = (2^20) + 1;
                int pid = fake++;
@@ -624,7 +624,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
                convert_ptr(new ForkedCall::SignalType);
        convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2));
 
-       ForkedCall call;
+       ForkedCall call(buffer_.filePath());
        int ret = call.startScript(command, convert_ptr);
 
        if (ret != 0) {
index a583d09ac8d3c8856ee45d7f04ebaf41f69af700..e52be699d921e0e7238d07005fe0cce05d0f8e35 100644 (file)
@@ -15,6 +15,7 @@
 #include "support/ForkedCalls.h"
 
 #include "support/debug.h"
+#include "support/environment.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
@@ -23,6 +24,8 @@
 
 #include "support/bind.h"
 
+#include "LyXRC.h"
+
 #include <cerrno>
 #include <queue>
 #include <sstream>
@@ -270,6 +273,25 @@ int ForkedProcess::waitForChild()
 //
 /////////////////////////////////////////////////////////////////////
 
+ForkedCall::ForkedCall(string const & path)
+       : cmd_prefix_(empty_string())
+{
+       if (path.empty() || lyxrc.texinputs_prefix.empty())
+               return;
+
+       string const texinputs = os::latex_path_list(
+                       replaceCurdirPath(path, lyxrc.texinputs_prefix));
+       string const sep = string(1, os::path_separator(os::TEXENGINE));
+       string const env = getEnv("TEXINPUTS");
+
+       if (os::shell() == os::UNIX)
+               cmd_prefix_ = "env 'TEXINPUTS=." + sep + texinputs
+                                                + sep + env + "' ";
+       else
+               cmd_prefix_ = "cmd /p /c set TEXINPUTS=." + sep + texinputs
+                                                         + sep + env + " & ";
+}
+
 
 int ForkedCall::startScript(Starttype wait, string const & what)
 {
@@ -296,7 +318,7 @@ int ForkedCall::startScript(string const & what, SignalTypePtr signal)
 // generate child in background
 int ForkedCall::generateChild()
 {
-       string line = trim(command_);
+       string const line = trim(cmd_prefix_ + command_);
        if (line.empty())
                return 1;
 
index caeba526e0eaf9a9afe703635fbc12ae651f9259..529f5c6861082a56b763108818d028939626d0b0 100644 (file)
 #define FORKEDCALLS_H
 
 #include "support/shared_ptr.h"
+#include "support/strfwd.h"
 #include <boost/signal.hpp>
 
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
 
-#include <string>
-
 namespace lyx {
 namespace support {
 
@@ -150,6 +149,8 @@ private:
 
 class ForkedCall : public ForkedProcess {
 public:
+       ///
+       ForkedCall(std::string const & path = empty_string());
        ///
        virtual shared_ptr<ForkedProcess> clone() const {
                return shared_ptr<ForkedProcess>(new ForkedCall(*this));
@@ -175,6 +176,8 @@ public:
 private:
        ///
        virtual int generateChild();
+       ///
+       std::string cmd_prefix_;
 };