X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsgml.cpp;h=2facb3ed539e280d459fed50a9f9fba1ba7f3b48;hb=cf14e814124ccbc8155fa1dde98d03be319c0e87;hp=125ef611fa89e345b18e00f23d8fec4cb8de0e3c;hpb=452a7a500c78aeb04f5a2695a368cfdc1efd4c0d;p=lyx.git diff --git a/src/sgml.cpp b/src/sgml.cpp index 125ef611fa..2facb3ed53 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -26,9 +26,10 @@ #include "support/docstream.h" #include "support/lstrings.h" #include "support/textutils.h" -#include "support/ThreadStorage.h" +#include #include +#include using namespace std; using namespace lyx::support; @@ -105,10 +106,8 @@ docstring sgml::escapeString(docstring const & raw) docstring const sgml::uniqueID(docstring const & label) { - // FIXME THREAD - // It seems unlikely there could be a problem here, - // but we could have concurrent access, in principle. - static unsigned int seed = 1000; + // thread-safe + static atomic_uint seed(1000); return label + convert(++seed); } @@ -137,10 +136,10 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, docstring content; typedef map MangledMap; - static ThreadStorage tMangledNames; - MangledMap & mangledNames = *tMangledNames; - static ThreadStorage tMangleID; - int & mangleID = *tMangleID; + static QThreadStorage tMangledNames; + static QThreadStorage tMangleID; + + MangledMap & mangledNames = tMangledNames.localData(); MangledMap::const_iterator const known = mangledNames.find(orig); if (known != mangledNames.end()) @@ -169,9 +168,10 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, } } - if (mangle) + if (mangle) { + int & mangleID = tMangleID.localData(); content += "-" + convert(mangleID++); - else if (isDigitASCII(content[content.size() - 1])) + } else if (isDigitASCII(content[content.size() - 1])) content += "."; mangledNames[orig] = content;