From: Georg Baum Date: Sun, 7 Dec 2014 17:26:44 +0000 (+0100) Subject: Make Language and Encoding threadsafe X-Git-Tag: 2.2.0alpha1~1476 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=25344de51d774de888631d3d85820a88ae99a80b;p=features.git Make Language and Encoding threadsafe Read-only access to these classes is now threadsafe, with one exception: The encoding neds to be already initialized (i.e. init() must not be called). This makes bug 9336 unreproducable on my machine, although it is not completely fixed yet. --- diff --git a/src/Encoding.h b/src/Encoding.h index 33919281d1..ebdfb98b0c 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -14,6 +14,7 @@ #define ENCODING_H #include "support/docstring.h" +#include "support/trivstring.h" #include "support/types.h" #include @@ -29,7 +30,7 @@ public: EncodingException(char_type c); virtual ~EncodingException() throw() {} virtual const char * what() const throw(); - + char_type failed_char; int par_id; pos_type pos; @@ -94,15 +95,15 @@ public: /// private: /// LaTeX command (text mode) for this character - docstring textcommand_; + trivdocstring textcommand_; /// LaTeX command (math mode) for this character - docstring mathcommand_; + trivdocstring mathcommand_; /// Needed LaTeX preamble (or feature) for text mode - std::string textpreamble_; + trivstring textpreamble_; /// Needed LaTeX preamble (or feature) for math mode - std::string mathpreamble_; + trivstring mathpreamble_; /// TIPA shortcut - std::string tipashortcut_; + trivstring tipashortcut_; /// feature flags unsigned int flags_; }; @@ -129,13 +130,13 @@ public: /// void init() const; /// - std::string const & name() const { return name_; } + std::string const name() const { return name_; } /// - std::string const & latexName() const { return latexName_; } + std::string const latexName() const { return latexName_; } /// - std::string const & guiName() const { return guiName_; } + std::string const guiName() const { return guiName_; } /// - std::string const & iconvName() const { return iconvName_; } + std::string const iconvName() const { return iconvName_; } /// bool hasFixedWidth() const { return fixedwidth_; } /// @@ -178,13 +179,13 @@ private: */ bool isForced(char_type c) const; /// - std::string name_; + trivstring name_; /// - std::string latexName_; + trivstring latexName_; /// - std::string guiName_; + trivstring guiName_; /// - std::string iconvName_; + trivstring iconvName_; /// Is this a fixed width encoding? bool fixedwidth_; /// Is this encoding TeX unsafe, e.g. control characters like {, } @@ -222,7 +223,7 @@ public: /// typedef std::set MathSymbolSet; /// - typedef std::map EncodingList; + typedef std::map EncodingList; /// iterator to iterate over all encodings. /// We hide the fact that our encoding list is implemented as a map. class const_iterator : public EncodingList::const_iterator { diff --git a/src/Language.h b/src/Language.h index 3e54d7bec8..6d54e2a201 100644 --- a/src/Language.h +++ b/src/Language.h @@ -16,6 +16,7 @@ #define LANGUAGE_H #include "support/docstring.h" +#include "support/trivstring.h" #include @@ -33,21 +34,21 @@ public: /// Language() : rightToLeft_(false) {} /// LyX language name - std::string const & lang() const { return lang_; } + std::string const lang() const { return lang_; } /// Babel language name - std::string const & babel() const { return babel_; } + std::string const babel() const { return babel_; } /// polyglossia language name - std::string const & polyglossia() const { return polyglossia_name_; } + std::string const polyglossia() const { return polyglossia_name_; } /// polyglossia language options - std::string const & polyglossiaOpts() const { return polyglossia_opts_; } + std::string const polyglossiaOpts() const { return polyglossia_opts_; } /// Is this language only supported by polyglossia? bool isPolyglossiaExclusive() const; /// quotation marks style - std::string const & quoteStyle() const { return quote_style_; } + std::string const quoteStyle() const { return quote_style_; } /// requirement (package, function) - std::string const & requires() const { return requires_; } + std::string const requires() const { return requires_; } /// translatable GUI name - std::string const & display() const { return display_; } + std::string const display() const { return display_; } /// is this a RTL language? bool rightToLeft() const { return rightToLeft_; } /** @@ -60,19 +61,19 @@ public: /// default encoding Encoding const * encoding() const { return encoding_; } /// - std::string const & encodingStr() const { return encodingStr_; } + std::string const encodingStr() const { return encodingStr_; } /// language code - std::string const & code() const { return code_; } + std::string const code() const { return code_; } /// set code (needed for rc.spellchecker_alt_lang) void setCode(std::string const & c) { code_ = c; } /// language variety (needed by aspell checker) - std::string const & variety() const { return variety_; } + std::string const variety() const { return variety_; } /// set variety (needed for rc.spellchecker_alt_lang) void setVariety(std::string const & v) { variety_ = v; } /// preamble settings after babel was called - std::string const & babel_postsettings() const { return babel_postsettings_; } + std::string const babel_postsettings() const { return babel_postsettings_; } /// preamble settings before babel is called - std::string const & babel_presettings() const { return babel_presettings_; } + std::string const babel_presettings() const { return babel_presettings_; } /// This language internally sets a font encoding bool internalFontEncoding() const { return internal_enc_; } /// This language needs to be passed to babel itself (not the class) @@ -82,40 +83,40 @@ public: /// bool readLanguage(Lexer & lex); /// - typedef std::map TranslationMap; + typedef std::map TranslationMap; /// void readLayoutTranslations(TranslationMap const & trans, bool replace); // for the use in std::map friend bool operator<(Language const & p, Language const & q); private: /// - std::string lang_; + trivstring lang_; /// - std::string babel_; + trivstring babel_; /// - std::string polyglossia_name_; + trivstring polyglossia_name_; /// - std::string polyglossia_opts_; + trivstring polyglossia_opts_; /// - std::string quote_style_; + trivstring quote_style_; /// - std::string requires_; + trivstring requires_; /// - std::string display_; + trivstring display_; /// bool rightToLeft_; /// - std::string encodingStr_; + trivstring encodingStr_; /// Encoding const * encoding_; /// - std::string code_; + trivstring code_; /// - std::string variety_; + trivstring variety_; /// - std::string babel_postsettings_; + trivstring babel_postsettings_; /// - std::string babel_presettings_; + trivstring babel_presettings_; /// bool internal_enc_; /// @@ -135,7 +136,7 @@ class Languages { public: /// - typedef std::map LanguageList; + typedef std::map LanguageList; /// typedef LanguageList::const_iterator const_iterator; ///