#include "output.h"
#include "OutputParams.h"
#include "TexRow.h"
+#include "texstream.h"
#include "frontends/Application.h" // hexName
#include "support/bind.h"
#include "support/TempFile.h"
-#include <sstream>
+#include <atomic>
#include <fstream>
#include <iomanip>
+#include <memory>
+#include <mutex>
+#include <sstream>
#include <QTimer>
return ptr;
}
- // FIXME THREAD
- static bool first = true;
- if (first) {
- first = false;
- LYXERR0("PreviewLoader::startLoading()\n"
- << "No converter from \"" << from << "\" format has been defined.");
- }
+ // Show the error only once
+#ifdef LYX_USE_STD_CALL_ONCE
+ // This is thread-safe.
+ static once_flag flag;
+ call_once(flag, [&](){
+ LYXERR0("PreviewLoader::startLoading()\n"
+ << "No converter from \"" << from
+ << "\" format has been defined.");
+ });
+#else
+ // This is also thread-safe according to ยง6.7.4 of the C++11 standard.
+ static bool once = ([&]{
+ LYXERR0("PreviewLoader::startLoading()\n"
+ << "No converter from \"" << from
+ << "\" format has been defined.");
+ } (), true);
+#endif
return 0;
}
namespace lyx {
namespace graphics {
-class PreviewLoader::Impl : public boost::signals::trackable {
+class PreviewLoader::Impl : public boost::signals2::trackable {
public:
///
Impl(PreviewLoader & p, Buffer const & b);
void refreshPreviews();
/// Emit this signal when an image is ready for display.
- boost::signal<void(PreviewImage const &)> imageReady;
+ boost::signals2::signal<void(PreviewImage const &)> imageReady;
Buffer const & buffer() const { return buffer_; }
/** cache_ allows easy retrieval of already-generated images
* using the LaTeX snippet as the identifier.
*/
- typedef shared_ptr<PreviewImage> PreviewImagePtr;
+ typedef std::shared_ptr<PreviewImage> PreviewImagePtr;
///
typedef map<string, PreviewImagePtr> Cache;
///
}
-boost::signals::connection PreviewLoader::connect(slot_type const & slot) const
+boost::signals2::connection PreviewLoader::connect(slot_type const & slot) const
{
return pimpl_->imageReady.connect(slot);
}
return;
}
- TexRow texrow;
- otexstream os(of, texrow);
+ otexstream os(of);
OutputParams runparams(&enc);
LaTeXFeatures features(buffer_, buffer_.params(), runparams);
}
of << "\\batchmode\n";
+ // Set \jobname of previews to the document name (see bug 9627)
+ of << "\\def\\jobname{"
+ << from_utf8(changeExtension(buffer_.latexName(true), ""))
+ << "}\n";
+
LYXERR(Debug::LATEX, "Format = " << buffer_.params().getDefaultOutputFormat());
string latexparam = "";
bool docformat = !buffer_.params().default_output_format.empty()
if (wait) {
ForkedCall call(buffer_.filePath(), buffer_.layoutPos());
int ret = call.startScript(ForkedProcess::Wait, command);
- // FIXME THREAD
- static int fake = (2^20) + 1;
+ static atomic_int fake((2^20) + 1);
int pid = fake++;
inprogress.pid = pid;
inprogress.command = command;