]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsConverter.cpp
Remove unused variables
[lyx.git] / src / graphics / GraphicsConverter.cpp
index f00f017e2e220e125e3684b0a9f7251b86292d7d..c97e76663d3b1d746a37e07627d587b18d196341 100644 (file)
 
 #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"
@@ -25,7 +22,6 @@
 #include "support/filetools.h"
 #include "support/ForkedCalls.h"
 #include "support/lstrings.h"
-#include "support/os.h"
 
 #include "support/TempFile.h"
 
@@ -42,7 +38,7 @@ namespace graphics {
 class Converter::Impl {
 public:
        ///
-       Impl(FileName const & doc_fname,
+       Impl(Converter const & parent, FileName const & doc_fname,
             FileName const & from_file, string const & to_file_base,
             string const & from_format, string const & to_format);
 
@@ -59,10 +55,12 @@ public:
        /** At the end of the conversion process inform the outside world
         *  by emitting a signal.
         */
-       typedef signals2::signal<void(bool)> sig;
+       typedef signal<void(bool)> sig;
        ///
        sig finishedConversion;
 
+       ///
+       Converter const & parent_;
        ///
        FileName const doc_fname_;
        ///
@@ -75,8 +73,6 @@ public:
        bool valid_process_;
        ///
        bool finished_;
-       ///
-       Trackable tracker_;
 };
 
 
@@ -90,23 +86,17 @@ bool Converter::isReachable(string const & from_format_name,
 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))
+       : pimpl_(make_shared<Impl>(*this, doc_fname, from_file, to_file_base, from_format, to_format))
 {}
 
 
-Converter::~Converter()
-{
-       delete pimpl_;
-}
-
-
 void Converter::startConversion() const
 {
        pimpl_->startConversion();
 }
 
 
-signals2::connection Converter::connect(slot_type const & slot) const
+connection Converter::connect(slot_type const & slot) const
 {
        return pimpl_->finishedConversion.connect(slot);
 }
@@ -127,10 +117,10 @@ static void build_script(string const & doc_fname,
                  ostream & script);
 
 
-Converter::Impl::Impl(FileName const & doc_fname,
+Converter::Impl::Impl(Converter const & parent, FileName const & doc_fname,
                      FileName const & from_file, string const & to_file_base,
                      string const & from_format, string const & to_format)
-       : doc_fname_(doc_fname), valid_process_(false), finished_(false)
+       : parent_(parent), doc_fname_(doc_fname), valid_process_(false), finished_(false)
 {
        LYXERR(Debug::GRAPHICS, "Converter c-tor:\n"
                << "doc_fname:        " << doc_fname
@@ -192,9 +182,12 @@ void Converter::Impl::startConversion()
        }
 
        ForkedCall::sigPtr ptr = ForkedCallQueue::add(script_command_);
-       ptr->connect(ForkedCall::slot([this](pid_t pid, int retval){
-                               converted(pid, retval);
-                       }).track_foreign(tracker_.p()));
+       weak_ptr<Converter::Impl> this_ = parent_.pimpl_;
+       ptr->connect([this_](pid_t pid, int retval){
+                       if (auto p = this_.lock()) {
+                               p->converted(pid, retval);
+                       }
+               });
 }
 
 
@@ -287,8 +280,7 @@ static void build_script(string const & doc_fname,
        LYXERR(Debug::GRAPHICS, "build_script ... ");
        typedef Graph::EdgePath EdgePath;
 
-       script << "#!/usr/bin/env python\n"
-                 "# -*- coding: utf-8 -*-\n"
+       script << "# -*- coding: utf-8 -*-\n"
                  "import os, shutil, sys\n\n"
                  "def unlinkNoThrow(file):\n"
                  "  ''' remove a file, do not throw if an error occurs '''\n"