message: Fix crash when pre-translating big XLIFF documents
  Massively-parallel local TM pre-translation could segfault, because
  Poedit didn't respect pugixml's (limited) thread-safety guarantees.
diff: #include <boost/algorithm/string.hpp>
  #include <memory>
  +#include <mutex>
  #include <set>
  #include <sstream>
  @@ -45,6 +46,11 @@ using namespace pugi;
  namespace
  {
  +// FIXME: This should be per-document mutex in XLIFFCatalog, but that is
  +// currently not accessible from XLIFFCatalogItem, hence a global.
  +std::mutex gs_documentMutex;
  +
  +
  inline bool has_child_elements(xml_node node)
  {
  return node.find_child([](xml_node n){ return n.type() == node_element; });
  @@ -511,6 +517,9 @@ public:
  {
  wxASSERT( m_translations.size() == 1 ); // no plurals
  + // modifications in the pugixml tree can affect other nodes, we must lock the entire document
  + std::lock_guard<std::mutex> lock(gs_documentMutex);
  +
  auto target = m_node.child("target");
  if (!target)
  {
  @@ -672,6 +681,9 @@ public:
  {
  wxASSERT( m_translations.size() == 1 ); // no plurals
  + // modifications in the pugixml tree can affect other nodes, we must lock the entire document
  + std::lock_guard<std::mutex> lock(gs_documentMutex);
  +
  auto target = m_node.child("target");
  if (!target)
  {
  