X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsgml.cpp;h=2facb3ed539e280d459fed50a9f9fba1ba7f3b48;hb=e040ccb0e86d8a928037e8b4b99f5ee786503abd;hp=3153ce37200113934c4eaafa5fe9c405d64fc0b3;hpb=fdbe775b9f5468e8f53dc83a66583f412b5970fb;p=lyx.git diff --git a/src/sgml.cpp b/src/sgml.cpp index 3153ce3720..2facb3ed53 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -27,7 +27,9 @@ #include "support/lstrings.h" #include "support/textutils.h" +#include #include +#include using namespace std; using namespace lyx::support; @@ -102,12 +104,10 @@ docstring sgml::escapeString(docstring const & raw) } -docstring const sgml::uniqueID(docstring const label) +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); } @@ -135,10 +135,11 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, docstring content; - // FIXME THREAD typedef map MangledMap; - static MangledMap mangledNames; - static int mangleID = 1; + static QThreadStorage tMangledNames; + static QThreadStorage tMangleID; + + MangledMap & mangledNames = tMangledNames.localData(); MangledMap::const_iterator const known = mangledNames.find(orig); if (known != mangledNames.end()) @@ -167,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;