X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsgml.cpp;h=2facb3ed539e280d459fed50a9f9fba1ba7f3b48;hb=b96ce9a9c101a711ef8a1cdd5d6fe812a18966da;hp=4842b07912e8f2f4524782a12093a5b3865174b8;hpb=2be29006adc748e343ad17126e0e62ef75b16afc;p=lyx.git diff --git a/src/sgml.cpp b/src/sgml.cpp index 4842b07912..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,9 +104,10 @@ docstring sgml::escapeString(docstring const & raw) } -docstring const sgml::uniqueID(docstring const label) +docstring const sgml::uniqueID(docstring const & label) { - static unsigned int seed = 1000; + // thread-safe + static atomic_uint seed(1000); return label + convert(++seed); } @@ -133,8 +136,10 @@ docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams, docstring content; 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()) @@ -163,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;