Add some missing locking.
authorCarl Hetherington <cth@carlh.net>
Thu, 9 Jun 2022 20:45:24 +0000 (22:45 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 Jun 2022 21:12:24 +0000 (23:12 +0200)
src/lib/text_content.cc
src/lib/text_content.h

index e91b7bcc039c7e8344414455a14883dd0a55301c..a85b271a88d23dbfca216491e5777e701c720f03 100644 (file)
@@ -445,7 +445,9 @@ TextContent::identifier () const
 void
 TextContent::add_font (shared_ptr<Font> font)
 {
-       DCPOMATIC_ASSERT(!get_font(font->id()));
+       boost::mutex::scoped_lock lm(_mutex);
+
+       DCPOMATIC_ASSERT(!get_font_unlocked(font->id()));
        _fonts.push_back (font);
        connect_to_fonts ();
 }
@@ -652,6 +654,14 @@ TextContent::take_settings_from (shared_ptr<const TextContent> c)
 
 shared_ptr<dcpomatic::Font>
 TextContent::get_font(string id) const
+{
+       boost::mutex::scoped_lock lm(_mutex);
+       return get_font_unlocked(id);
+}
+
+
+shared_ptr<dcpomatic::Font>
+TextContent::get_font_unlocked(string id) const
 {
        auto iter = std::find_if(_fonts.begin(), _fonts.end(), [&id](shared_ptr<dcpomatic::Font> font) {
                return font->id() == id;
@@ -668,6 +678,8 @@ TextContent::get_font(string id) const
 void
 TextContent::clear_fonts()
 {
+       boost::mutex::scoped_lock lm(_mutex);
+
        _fonts.clear();
 }
 
index 7ddb20b080dabc63e503393c195c247cf9396830..7c060cd482afb76fa3bdd152bb8dd178c4d2350f 100644 (file)
@@ -206,6 +206,7 @@ private:
 
        void font_changed ();
        void connect_to_fonts ();
+       std::shared_ptr<dcpomatic::Font> get_font_unlocked(std::string id) const;
 
        std::list<boost::signals2::connection> _font_connections;