Also set TEXINPUTS when launching ForkedCall processes.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39742 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2011-09-24 01:32:35 +00:00
parent a55f54b903
commit 5c17ce4195
3 changed files with 30 additions and 5 deletions

View 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) {

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

View File

@ -15,14 +15,13 @@
#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_;
};