X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgraphics%2FPreviewLoader.cpp;h=de04e4db50ffbd7612daf909b52702f1350e1885;hb=649755f48180b0466cdf212178dc9bdcc5d18210;hp=d0590f6b2882387524d153f8fabe50ba8d49ad72;hpb=5999dd96e64c707339c7cd05b81956017080fbb3;p=lyx.git diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index d0590f6b28..de04e4db50 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -180,7 +180,7 @@ public: void refreshPreviews(); /// Emit this signal when an image is ready for display. - signals2::signal imageReady; + signal imageReady; Buffer const & buffer() const { return buffer_; } @@ -226,8 +226,6 @@ private: /// QTimer * delay_refresh_; /// - Trackable trackable_; - /// bool finished_generating_; /// We don't own this @@ -244,16 +242,10 @@ lyx::Converter const * PreviewLoader::Impl::pconverter_; // PreviewLoader::PreviewLoader(Buffer const & b) - : pimpl_(new Impl(*this, b)) + : pimpl_(make_shared(*this, b)) {} -PreviewLoader::~PreviewLoader() -{ - delete pimpl_; -} - - PreviewImage const * PreviewLoader::preview(string const & latex_snippet) const { return pimpl_->preview(latex_snippet); @@ -290,7 +282,7 @@ void PreviewLoader::refreshPreviews() } -signals2::connection PreviewLoader::connect(slot const & slot) const +connection PreviewLoader::connect(slot const & slot) const { return pimpl_->imageReady.connect(slot); } @@ -721,9 +713,12 @@ void PreviewLoader::Impl::startLoading(bool wait) // Initiate the conversion from LaTeX to bitmap images files. ForkedCall::sigPtr convert_ptr = make_shared(); - convert_ptr->connect(ForkedProcess::slot([this](pid_t pid, int retval){ - finishedGenerating(pid, retval); - }).track_foreign(trackable_.p())); + weak_ptr this_ = parent_.pimpl_; + convert_ptr->connect([this_](pid_t pid, int retval){ + if (auto p = this_.lock()) { + p->finishedGenerating(pid, retval); + } + }); ForkedCall call(buffer_.filePath()); int ret = call.startScript(command, convert_ptr); @@ -824,11 +819,11 @@ void PreviewLoader::Impl::dumpPreamble(otexstream & os, Flavor flavor) const buffer_.writeLaTeXSource(os, buffer_.filePath(), runparams, Buffer::OnlyPreamble); // FIXME! This is a HACK! The proper fix is to control the 'true' - // passed to WriteStream below: + // passed to TeXMathStream below: // int InsetMathNest::latex(Buffer const &, odocstream & os, // OutputParams const & runparams) const // { - // WriteStream wi(os, runparams.moving_arg, true); + // TeXMathStream wi(os, runparams.moving_arg, true); // par_->write(wi); // return wi.line(); // }