Use call_once to ensure something is only called once

This is thread-safe.
This commit is contained in:
Guillaume Munch 2016-07-30 20:46:29 +01:00
parent 46d8dfc6c2
commit 22d7ba6424

View File

@ -45,6 +45,7 @@
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <memory> #include <memory>
#include <mutex>
#include <sstream> #include <sstream>
#include <QTimer> #include <QTimer>
@ -91,13 +92,13 @@ lyx::Converter const * setConverter(string const & from)
return ptr; return ptr;
} }
// FIXME THREAD // Show the error only once
static bool first = true; static once_flag flag;
if (first) { call_once(flag, [&](){
first = false; LYXERR0("PreviewLoader::startLoading()\n"
LYXERR0("PreviewLoader::startLoading()\n" << "No converter from \"" << from
<< "No converter from \"" << from << "\" format has been defined."); << "\" format has been defined.");
} });
return 0; return 0;
} }