X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsConverter.cpp;h=598e108b73a153f1882eb8c618c747936b6f4936;hb=ab81c23656b59aa14c41b8acc45f0f3e410ed785;hp=67b1580fd93bdc74de103d02a613e7269c8ab78c;hpb=8b5dc3c6623271d27807a20d29b738f6790c346a;p=lyx.git diff --git a/src/graphics/GraphicsConverter.cpp b/src/graphics/GraphicsConverter.cpp index 67b1580fd9..598e108b73 100644 --- a/src/graphics/GraphicsConverter.cpp +++ b/src/graphics/GraphicsConverter.cpp @@ -12,9 +12,12 @@ #include "GraphicsConverter.h" +#include "Buffer.h" #include "Converter.h" #include "Format.h" +#include "LyXRC.h" +#include "frontends/alert.h" #include "support/lassert.h" #include "support/convert.h" #include "support/debug.h" @@ -24,7 +27,6 @@ #include "support/lstrings.h" #include "support/os.h" -#include "support/bind.h" #include "support/TempFile.h" #include @@ -37,10 +39,12 @@ namespace lyx { namespace graphics { -class Converter::Impl : public boost::signals2::trackable { +class Converter::Impl { public: /// - Impl(FileName const &, string const &, string const &, string const &); + Impl(FileName const & doc_fname, + FileName const & from_file, string const & to_file_base, + string const & from_format, string const & to_format); /// void startConversion(); @@ -55,10 +59,12 @@ public: /** At the end of the conversion process inform the outside world * by emitting a signal. */ - typedef boost::signals2::signal SignalType; + typedef signals2::signal sig; /// - SignalType finishedConversion; + sig finishedConversion; + /// + FileName const doc_fname_; /// string script_command_; /// @@ -69,6 +75,8 @@ public: bool valid_process_; /// bool finished_; + /// + Trackable tracker_; }; @@ -79,9 +87,10 @@ bool Converter::isReachable(string const & from_format_name, } -Converter::Converter(FileName const & from_file, string const & to_file_base, - string const & from_format, string const & to_format) - : pimpl_(new Impl(from_file, to_file_base, from_format, to_format)) +Converter::Converter(FileName const & doc_fname, + FileName const & from_file, string const & to_file_base, + string const & from_format, string const & to_format) + : pimpl_(new Impl(doc_fname, from_file, to_file_base, from_format, to_format)) {} @@ -97,7 +106,7 @@ void Converter::startConversion() const } -boost::signals2::connection Converter::connect(slot_type const & slot) const +signals2::connection Converter::connect(slot_type const & slot) const { return pimpl_->finishedConversion.connect(slot); } @@ -112,17 +121,20 @@ FileName const & Converter::convertedFile() const /** Build the conversion script. * The script is output to the stream \p script. */ -static void build_script(string const & from_file, string const & to_file_base, +static void build_script(string const & doc_fname, + string const & from_file, string const & to_file_base, string const & from_format, string const & to_format, ostream & script); -Converter::Impl::Impl(FileName const & from_file, string const & to_file_base, +Converter::Impl::Impl(FileName const & doc_fname, + FileName const & from_file, string const & to_file_base, string const & from_format, string const & to_format) - : valid_process_(false), finished_(false) + : doc_fname_(doc_fname), valid_process_(false), finished_(false) { LYXERR(Debug::GRAPHICS, "Converter c-tor:\n" - << "\tfrom_file: " << from_file + << "doc_fname: " << doc_fname + << "\n\tfrom_file: " << from_file << "\n\tto_file_base: " << to_file_base << "\n\tfrom_format: " << from_format << "\n\tto_format: " << to_format); @@ -130,11 +142,11 @@ Converter::Impl::Impl(FileName const & from_file, string const & to_file_base, // The converted image is to be stored in this file (we do not // use ChangeExtension because this is a basename which may // nevertheless contain a '.') - to_file_ = FileName(to_file_base + '.' + formats.extension(to_format)); + to_file_ = FileName(to_file_base + '.' + theFormats().extension(to_format)); // The conversion commands are stored in a stringstream ostringstream script; - build_script(from_file.toFilesystemEncoding(), + build_script(doc_fname_.absFileName(), from_file.toFilesystemEncoding(), to_file_.toFilesystemEncoding(), from_format, to_format, script); LYXERR(Debug::GRAPHICS, "\tConversion script:" @@ -179,9 +191,10 @@ void Converter::Impl::startConversion() return; } - ForkedCall::SignalTypePtr ptr = - ForkedCallQueue::add(script_command_); - ptr->connect(bind(&Impl::converted, this, _1, _2)); + ForkedCall::sigPtr ptr = ForkedCallQueue::add(script_command_); + ptr->connect(ForkedCall::slot([this](pid_t pid, int retval){ + converted(pid, retval); + }).track_foreign(tracker_.p())); } @@ -263,7 +276,8 @@ static string const strip_digit(string const & format) } -static void build_script(string const & from_file, +static void build_script(string const & doc_fname, + string const & from_file, string const & to_file, string const & from_format, string const & to_format, @@ -372,6 +386,9 @@ static void build_script(string const & from_file, outfile = tempfile.name().toFilesystemEncoding(); } + if (!theConverters().checkAuth(conv, doc_fname)) + return; + // Store these names in the python script script << "infile = " << quoteName(infile, quote_python) << "\n"