From: Enrico Forestieri Date: Sat, 24 Sep 2011 01:32:35 +0000 (+0000) Subject: Also set TEXINPUTS when launching ForkedCall processes. X-Git-Tag: 2.1.0beta1~2668 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5c17ce4195197220f809b9b1809c52fe1346dc16;p=features.git Also set TEXINPUTS when launching ForkedCall processes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39742 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index feadc45c9e..eadcd93f23 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -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) { diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp index a583d09ac8..e52be699d9 100644 --- a/src/support/ForkedCalls.cpp +++ b/src/support/ForkedCalls.cpp @@ -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 #include #include @@ -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; diff --git a/src/support/ForkedCalls.h b/src/support/ForkedCalls.h index caeba526e0..529f5c6861 100644 --- a/src/support/ForkedCalls.h +++ b/src/support/ForkedCalls.h @@ -15,14 +15,13 @@ #define FORKEDCALLS_H #include "support/shared_ptr.h" +#include "support/strfwd.h" #include #ifdef HAVE_SYS_TYPES_H # include #endif -#include - namespace lyx { namespace support { @@ -150,6 +149,8 @@ private: class ForkedCall : public ForkedProcess { public: + /// + ForkedCall(std::string const & path = empty_string()); /// virtual shared_ptr clone() const { return shared_ptr(new ForkedCall(*this)); @@ -175,6 +176,8 @@ public: private: /// virtual int generateChild(); + /// + std::string cmd_prefix_; };