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 <iomanip>
#include <memory>
#include <mutex>
#include <sstream>
#include <QTimer>
@ -91,13 +92,13 @@ lyx::Converter const * setConverter(string const & from)
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
static once_flag flag;
call_once(flag, [&](){
LYXERR0("PreviewLoader::startLoading()\n"
<< "No converter from \"" << from
<< "\" format has been defined.");
});
return 0;
}