commit 22d7ba642415f576e9553b174166d8c17b945f39
Author: Guillaume Munch <[email protected]>
Date:   Sat Jul 30 20:46:29 2016 +0100

    Use call_once to ensure something is only called once
    
    This is thread-safe.
---
 src/graphics/PreviewLoader.cpp |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index 1240771..f8c1d7e 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -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;
 }
 

Reply via email to