]> git.lyx.org Git - features.git/commitdiff
Fix multithreading crash (bug #9366)
authorGeorg Baum <baum@lyx.org>
Mon, 5 Jan 2015 20:44:37 +0000 (21:44 +0100)
committerGeorg Baum <baum@lyx.org>
Mon, 5 Jan 2015 20:44:37 +0000 (21:44 +0100)
This minimal fix makes the crash go away on my machine. A much more complete
fix is in master (and will be futher extended), but for 2.1.x we'll do only
minimal changes.

src/Language.cpp
src/Language.h
src/support/lstrings.h
status.21x

index e6f7f9ed6a940a261b6a604b9c54b210936527d7..6b624fc21b9e7a3807fcd51ae136abf031540823 100644 (file)
@@ -38,6 +38,12 @@ Language const * latex_language = 0;
 Language const * reset_language = 0;
 
 
+std::string const Language::babel() const
+{
+       return deep_copy(babel_);
+}
+
+
 bool Language::isPolyglossiaExclusive() const
 {
        return babel().empty() && !polyglossia().empty() && requires().empty();
index c912326a89793c6a5b4076d300ff0d6dc184a78e..7b6410d168e2484ad2254cf74477c816708e2c28 100644 (file)
@@ -35,7 +35,7 @@ public:
        /// LyX language name
        std::string const & lang() const { return lang_; }
        /// Babel language name
-       std::string const & babel() const { return babel_; }
+       std::string const babel() const;
        /// polyglossia language name
        std::string const & polyglossia() const { return polyglossia_name_; }
        /// polyglossia language options
index 20a73c4a4d6edf02fee4f907a9232837b7257395..3a69df4cdba941ec62a8ee64677dda262e4e7f27 100644 (file)
 namespace lyx {
 namespace support {
 
+/// Helper to enforce creating a deep copy of lyx::docstring or std::string
+/// even if std::basic_string uses copy-on-write as in GNU libstdc++.
+/// \sa https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334
+template<typename Char, typename Traits, typename Alloc>
+typename std::basic_string<Char, Traits, Alloc>
+deep_copy(typename std::basic_string<Char, Traits, Alloc> const & src)
+{
+       typedef typename std::basic_string<Char, Traits, Alloc> String;
+       // Use constructor with two arguments to support strings with embedded
+       // \0 characters
+       return String(src.c_str(), src.length());
+}
+
 /// Compare \p s and \p s2, ignoring the case.
 /// Does not depend on the locale.
 int compare_no_case(docstring const & s, docstring const & s2);
index b591ba20cc29ecee25830cdb81b2eabc8ec7d5cf..7f199e4251296ecad34ce58994551916817e8a41 100644 (file)
@@ -158,6 +158,9 @@ What's new
 - Fix logic of "Maintain aspect ratio" checkbox in the graphics dialog
   (bug 9357).
 
+- Fix most frequent reason for crash while editing with open view source
+  window (bug 9336).
+
 
 * INTERNALS