#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"
#include "support/filetools.h"
#include "support/ForkedCalls.h"
#include "support/lstrings.h"
-#include "support/os.h"
#include "support/TempFile.h"
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);
/** 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_;
///
bool valid_process_;
///
bool finished_;
- ///
- Trackable tracker_;
};
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);
}
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
}
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);
+ }
+ });
}
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"