On Sun, Jul 31, 2016 at 07:36:26PM +0200, Guillaume Munch wrote:

> commit 22d7ba642415f576e9553b174166d8c17b945f39
> Author: Guillaume Munch <g...@lyx.org>
> Date:   Sat Jul 30 20:46:29 2016 +0100
> 
>     Use call_once to ensure something is only called once
>     
>     This is thread-safe.

This does not compile with mingw (g++ 4.9.2):

i686-w64-mingw32-g++ -DHAVE_CONFIG_H -I. -I../../src -I..  -I../../src 
-I../../3rdparty/boost    -I/c/MinGW/include/hunspell  -DQT_NO_STL 
-DQT_NO_KEYWORDS -I/c/MinGW/Qt/5.7.0/include/QtCore -I/c/MinGW/Qt/5.7.0/include 
 -pipe -fno-keep-inline-dllexport -I/c/MinGW/include  -O2 -std=c++14   -MT 
graphics/PreviewLoader.o -MD -MP -MF graphics/.deps/PreviewLoader.Tpo -c -o 
graphics/PreviewLoader.o ../../src/graphics/PreviewLoader.cpp

../../src/graphics/PreviewLoader.cpp: In function ‘const lyx::Converter* 
{anonymous}::setConverter(const string&)’:
../../src/graphics/PreviewLoader.cpp:96:9: error: ‘once_flag’ does not name a 
type
  static once_flag flag;
         ^
../../src/graphics/PreviewLoader.cpp:97:12: error: ‘flag’ was not declared in 
this scope
  call_once(flag, [&](){
            ^
../../src/graphics/PreviewLoader.cpp:101:4: error: ‘call_once’ was not declared 
in this scope
   });
    ^


> ---
>  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;
>  }
>  

-- 
Enrico

Reply via email to